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:
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
;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
- AutoIt - Copy file
- AutoIt - Move file
- AutoIt - Delete file
- AutoIt - Rename a file
- AutoIt - Check if a file or folder is Read Only
- AutoIt - Set a file or folder as Read Write
Interesting? Share and Let Others Know.
Post a Comment