Skip to main content

TrFile_Exists (function reference)

By June 1, 2024June 4th, 2024Online Help, Troi File Plug-in
Troi File Plug-in for FileMaker Pro

TrFile_Exists

Check for the existence of a file or folder.

SyntaxFunction badge

TrFile_Exists ( switches ; filePath )

Parameters

switches not used, reserved for future use. Leave blank or put "-Unused"
filePath the path to the file for which you want to know if it exists

Returned Result

Data type returned

Number

Result

The returned result is a boolean: the function returns 1 if the file or folder exists. If it does not exist or if an error occurs it will return 0.

Originated in

Troi File Plug-in 3.1

Compatibility

FileMaker Pro 17 to FileMaker Pro 21 (2024)

Considerations

If the function returns 0 you should decide if it is necessary to check for errors, for example if a file is on a disk that is not mounted.

Example

Set Field [ doesExists ; TrFile_Exists ( "-Unused" ;  "C:\Test.txt" ) ]

This will return 1 if it exists.

Example 2

We assume that in your FileMaker file the following field is defined:

  gFilePath		Global, text

gFilePath should contain the path to a file, for example “D:\Logs\L2000_01.TXT” (Windows) or “Mac HD:Logs:Log 2000_01” (Mac). In a script add the following script steps:

if [ TrFile_Exists ( "-Unused" ;  gFilePath ) ]
   # ... do your stuff here
else
   # ... do your error handling here....
endif

This will make it easy to handle existing files.

Used in example file

Attribute.fmp12

Related functionsFunction badge

TrFile_GetDateModified
TrFile_GetTimestampCreated
TrFile_IsFree
TrFile_SelectFileDialog

Related topics

Troi File Plug-in online help (overview)


Online Help Page for Troi File Plug-in for 17 to 2024 –> TrFile_Exists (filep4216) 2024-0604 19:36:39