Opens a text file for reading or writing.
FileOpen ( "filename", mode )
Parameters
filename | Filename of the text file to open. |
mode | Mode (read or write) to open the file in. 0 = Read mode 1 = Write mode (append to end of file) 2 = Write mode (erase previous contents) Both write modes will create the file if it does not already exist. |
Return Value
Success: | Returns a file "handle" or use with subsequent file functions. |
Failure: | Returns -1 if error occurs. |
Remarks
Up to 64 files can be open simultaneously by one AutoIt script. Exceeding this limit throws a run-time error and
Related
FileClose, FileReadLine, FileWriteLine, FileRead
Example
$file = FileOpen("test.txt", 0)
; Check if file opened for reading OK
If $file = -1 Then
MsgBox(0, "Error", "Unable to open file.")
Exit
EndIf
FileClose($file)