Method: FileExists for FileSystemObject
- Updated2024-09-12
- 1 minute(s) read
FileSystemObject and Dictionary > Methods > Method: FileExists for FileSystemObject
Method: FileExists for FileSystemObject
Checks whether a file exists.
bFileExists = Object.FileExists(FileSpec)
| Object | FileSystemObject Object with this method |
| FileSpec | String Specifies the path of the file. |
| bFileExists | Boolean If the file exists, the value is True. If the file does not exist, the value is False. |
The following example checks whether a file exists:
Function FileStatus(sFile) Dim fso, sOutput Set fso = CreateObject("Scripting.FileSystemObject") If (fso.FileExists(sFile)) Then sOutput = sFile & " exists." Else sOutput = sFile & " doesn't exist." End If FileStatus = sOutput End Function