Check Whether a File Exists in VB Script

In vb script we can check whether a file exists or not using the 'FileExists' function in File System Object. The syntax of FileExists function is given below

FileExists ( FileName ) 

Following example demonstrates how to check for the existence of a file

Dim fs
Set fs = CreateObject("Scripting.FileSystemObject")

If fs.FileExists("C:\File-1.txt") Then
	WScript.Echo("File Exists!!")
Else
	WScript.Echo("File Does not Exist")
End If
Powered by Bullraider.com