Returns True if a specified file exists; False if it does not.
object.FileExists(filespec)
The following example illustrates the use of the FileExists method.
[JScript] function ReportFileStatus(filespec) { var fso, s = filespec; fso = new ActiveXObject("Scripting.FileSystemObject"); if (fso.FileExists(
filespec)
) s += " exists."; else s += " doesn't exist."; return(s); } [VBScript] Function ReportFileStatus(filespec) Dim fso, msg Set fso = CreateObject("Scripting.FileSystemObject") If (fso.FileExists(
filespec)
) Then msg = filespec & " exists." Else msg = filespec & " doesn't exist." End If ReportFileStatus = msg End Function
DriveExists Method | FolderExists Method | GetFile Method | GetFileName Method
Applies To: FileSystemObject Object