ASP Tutorials - Check if a file exists using the File System Object

The File System Object has a method which checks if a file exists.

The following example checks if a file exists. It uses a physical path to the file and returns true or false.

Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Response.Write FSO.FileExists(FilePath)

FilePath could be a variable containing the path to the file or the path, such as "c:\inetpub\wwwroot\mysite\somefile.asp"


The sample code in these tutorials is written for VBScript in classic ASP unless otherwise stated. The code samples can be freely copied.