By using this site you agree to the use of cookies by Brugbart and our partners.

Learn more

AutoIt FileClose Function

Reference on the FileClose Function of AutoIt.

Edited: 2015-02-13 00:10

The AutoIt FileClose Function is used to close a file that has previously been opened using FileOpen, as well as search handles returned by FileFindFirstFile.

AutoIt automatically closes opened files when exiting, so using FileClose is likely only necessary under special circumstances. You can not use filenames when using FileClose – when using filenames rather than handles, with functions such as FileRead, the files will automatically be opened and closed.

Returns 1 on success, and 0 if the filehandle was invalid.

AutoIt FileClose Example

The below is an example that uses FileClose after opening a file, and writing a couple of lines to the file.

$file = FileOpen("SomeFile.txt", 1)

FileWrite($file, "This is the first line written with AutoIt." & @CRLF) ; The CRLF at the end is a line break
FileWrite($file, "Second line of the file.")