LATEST UPDATES
ShareHolder Finder v0.9.3 is now released!!! Check Product Page for more details.
✉ info@automationdevelopers.com

ITS ALL ABOUT AUTOMATION

Saturday, 16 April 2016

AutoIt - Check if a file exists


Author Post Date Saturday, 16 April 2016
To check if a file exists, the function FileExists ("path") is used. The path can be path to a file or a directory.
The function returns 1 for success and 0 if path/ file does not exist.

Example:

#include <MsgBoxConstants.au3>

;Assign the file path to a variable.
Local $sFilePath = "C:\AutomationDevelopers\temp.txt"

;Check if file exists.
Local $iFileExists = FileExists($sFilePath)

;Display a message after checking the returned value.
If $iFileExists Then
    MsgBox($MB_SYSTEMMODAL, "", "The file exists." & @CRLF & "FileExist returned: " & $iFileExists)
Else
    MsgBox($MB_SYSTEMMODAL, "", "The file doesn't exist." & @CRLF & "FileExist returned: " & $iFileExists)
EndIf

Related Posts




Interesting? Share and Let Others Know.

Post a Comment