FileExists (function)

Syntax

FileExists(filename$)

Description

Returns True if filename$ exists; returns False otherwise.

Comments

This function determines whether a given filename$ is valid.

This function will return False if filename$ specifies a subdirectory.

Example

This example checks to see whether there is an autoexec.bat file in the root directory of the C drive, then displays either its creation date and time or the fact that it does not exist.

Sub Main()
  If FileExists("c:\autoexec.bat") Then
    Msgbox "This file exists!"
  Else
    MsgBox "File does not exist."
  End If
End Sub

See Also

FileLen (function); GetAttr (function); FileAttr (function); FileParse$ (function).

More information

F