Home | Sign in | English EN

  • Caution: fDir keeps access to the directory
  • Looping through directories
  • Windows
  • Using fDir in threads
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WindowsLinuxPHPWEBDEV - Browser code
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Stored procedures
Finds a file or directory. This search can be performed with wildcard characters (*,?).
WINDEVWEBDEV - Server codeReports and QueriesJavaUser code (UMC)PHPAjax
// Find the "C:\MyDirectory\MyFile.doc" file
ResSearch = fDir("C:\MyDirectory\MyFile.doc")
// Find the "C:\MyDirectory\MyFile.doc" file
ResSearch = fDir("C:\MyDirectory\MyFile.doc", frFile)
// Find the "C:\MyDirectory\" directory
ResSearch = fDir("C:\MyDirectory\", frDirectory)
// Find the first ".doc" file in the "C:\MyDirectory" directory
ResSearch = fDir("C:\MyDirectory\*.doc")
<Result> = fDir(<Name of sought file or directory> [, <Options>])
<Result>: Character string
  • Name of file (with its extension) or directory found.
  • Empty string ("") otherwise. To determine if this function has generated an error, use ErrorInfo with the errMessage constant.
<Name of sought file or directory>: Character string
Name and full (or relative) path of the sought file or directory (up to 260 characters). A UNC path can be used. You have the ability to use wildcard characters (*,?) in the name of the file.
If this parameter is empty, the function continues and searches for the name of the next corresponding file (or directory): this allows you to list the files or directories belonging to a given directory.
If this parameter corresponds to a directory name, this name may (or may not) end with "\".
WindowsLinux This parameter can be in Ansi or Unicode format.
AndroidAndroid Widget This parameter can correspond to a full path or a path relative to the current directory (returned by fCurrentDir). This parameter is case-sensitive.
Reminder: In Android, the file system is read-only on the device and on the emulator. An application can only write to its setup directory or one of its subdirectories, as well as to the external memory (SDCard).
AndroidAndroid Widget Java If "*.*" is used, only files with an extension will be searched.
iPhone/iPadIOS WidgetMac Catalyst This parameter can correspond to a full path or a path relative to the current directory (returned by fCurrentDir). This parameter is case-sensitive.
Reminder: On iPhone/iPad, an application has the rights to write into its setup directory or into one of its subdirectories.
<Options>: Optional Integer constant (or combination of constants)
Search options:
fPathUNICODE<Result> will be a Unicode string.
This constant can be combined with frFile or frDirectory.
frDirectoryFind a directory.
(Default value)
Find a file.

Caution: fDir keeps access to the directory

Calling fDir keeps an access to the directory, and prevents you from deleting or renaming it. To unlock the directory, add the following line of code to your process:

Looping through directories

Directory iterations performed with fDir must not be nested.
fDir must not be used when fCopyFile is used to a loop through directories.


In Windows, a file name or a directory name can contain lowercase and/or uppercase characters (the names of the files are not "case sensitive").
Therefore, you should not write:
IF fDir(FileName) = "TOTO" THEN Info("File found")
But you should write:
IF fDir(FileName) ~= "TOTO" THEN Info("File found")

Using fDir in threads

It is not recommended to use fDir at the same time in two different threads.
The last iteration started with fDir automatically replaces the current iteration.
Component: wd270std.dll
Minimum version required
  • Version 9
This page is also available for…
Click [Add] to post a comment