Skip to content

File_Exist

See Also: File I/O Commands, Get_Directory, Make_Directory, Make_Temp_File, Remove_Directory, Valid_Drive, Get_File_Path

Purpose

Checks whether a file or folder exists.

Syntax

File_Exist {target} {result}

Parameters

  • {target}: The specification of a file or folder, optionally including a path.
  • {result}: A Boolean variable that is set to True if {target} exists, or False if it does not.

What It Does

File_Exist returns True if the specified target exists, and False if it does not. File_Exist will look for the target in the current working folder unless a path name is provided as part of the file or folder specification. You may use any valid Windows file or folder specification (excluding wildcard characters), including universal naming convention (UNC).

Examples

Example 1

The sample checks whether the file "hello.txt" exists in the current working folder (since a path is not specified).

Procedure DoesFileExist
    Boolean bFileExists
    File_Exist "hello.txt" bFileExists
End_Procedure

Send DoesFileExist

Example 2

The sample checks whether the folder "C:\temp" exists.

Procedure DoesFileExist
    Boolean bFileExists
    File_Exist "C:\temp" bFileExists
End_Procedure

Send DoesFileExist

Notes

  • No wildcards may be used.
  • File_Exist looks for the file in the current folder if no path is specified. You can use Get_Current_Directory to query the current folder.
  • It does not use the DFPATH Registry key value.
  • When testing for the existence of a folder, {target} should not have a trailing backslash.