AutoIt FileRead Function
The FileRead function is used in combination with FileOpen to read files.
Edited: 2017-12-19 17:42
The AutoIt FileRead function can be used to read files, and save their contents into a variable for later use.
If a filename is used instead of a file handle, the file will be opened and closed doing function call. This will be slower than using file handles when parsing larger files, so it might be better to use file handles.
FileRead can be used when working with custom configuration files for your scripts. An alternative is to use .ini files in combination with AutoIt's ini-functions. I.e: IniRead and IniWrite
Loading a file with FileRead
To read a file, it should first be opened for reading using FileOpen, then we can load it into a variable using FileRead. In the below example, the content of the loaded file is displayed using a message box.
$file = FileOpen("test.txt", 0) $FileContent = FileRead($file) MsgBox(0, "Content:", $FileContent) FileClose($file)
Parameters
filename | Handle of previously opened file. |
count optional | The number of characters to read. Reads the entire file by default. |
Tell us what you think: