AutoIt FileClose Function

Files that are opened with FileOpen can be closed using the FileClose function.

1408 views

Edited: 2017-03-26 15:13

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.")

FileClose($file)

Tell us what you think:

  1. How to declare and work with variables in AutoIt, as well as some background information.
  2. Everything you need to know about working with minimized windows.
  3. How to set the request headers when performing HTTP requests.
  4. This Tutorial will focus on post requests in AutoIt, using the Winhttprequest.5.1 object.
  5. How to use while, for, and do until loops, and how to loop through arrays and object in AutoIt.

More in: AutoIt Tutorials