ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Standard functions / External file functions
  • Handling errors
  • Listing the subdirectories of a directory
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Lists the files found in a directory and returns the list of files. The listed files are sought from the given directory.
Other use: For each file found, the fListFile function can automatically call a specific procedure written in WLanguage.. This procedure is used to handle the current file. In this case, fListFile returns the number of listed files.
Note: Under 64-bit Windows, access to a system directory from a 32-bit executable may be performed in a directory other than the expected one.. For more details, see Native 64-bit and native 32-bit.
WINDEVReports and QueriesUser code (UMC)PHPAjax
UnFichier, ResListeFichier are strings
// Liste les fichiers de type ".BMP" présents dans "C:\MesDocuments".
// Le parcours se fait également dans les sous-répertoires et est interruptible. 
ResListeFichier = fListFile("C:\MesDocuments\*.BMP", frRecursive + fdInterruptible)
// Pour chaque fichier trouvé
FOR EACH STRING UnFichier OF ResListeFichier SEPARATED BY CR
	// Ajout du fichier dans la table TABLE_TableFic
	TableAdd(TABLE_TableFic, UnFichier)
END
WINDEVWEBDEV - Server codeReports and QueriesJavaUser code (UMC)PHPAjax
// Liste les fichiers de type ".BMP" présents dans "C:\MesDocuments".
// La procédure AttributFichier retourne le nombre de fichiers en lecture seule.
ResListeFichier = fListFile("C:\MesDocuments\*.BMP", "AttributFichier")
Syntax

Listing the files found in a directory Hide the details

<Result> = fListFile(<Path and generic name of files> , <Options>)
<Result>: Character string
Full name of listed files, separated by CR characters (Carriage Return).

Attention: The function returns files whose short or long name matches the filter.
<Path and generic name of files>: Character string
Path and generic name of files to list. Generic characters (* and?) are allowed. Special cases:
  • if directory and drive not specified: the search path is built up from the current drive and the current directory for that drive.
  • if the drive is not specified but the directory is: the search path is formed from the current drive and the directory passed as a parameter.
  • if the drive is specified while the directory is not specified, the search path is built from the specified drive and from the current directory for this drive.
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 installation directory or one of its subdirectories, as well as to the external memory (SDCard).
iPhone/iPad 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 or iPad, an application has the rights to write to its installation directory or one of its subdirectories
<Options>: Combination of Integer constants
Option used to define the information returned as well as the type of iteration performed for the directory files:
fdFullInformationEach line (separated by carriage return - CR) contains the following information:
<Nom du fichier complet> + TAB + <Taille en octets> + TAB +
<Date de dernière modification> + TAB + <Attributs du fichier>
The date is in YYYYMMDDHHmmSS format. The attributes are identical to the ones returned by fAttribute.
fdInterruptibleThe iteration can be interrupted by pressing ESC. The function will return the name of the listed files until the interruption.
frNoHiddenDirectoryIf the frFullInformation constant is used, the hidden directories are not listed (attribute = "H").
frNoHiddenFileIf the frFullInformation constant is used, the hidden files are not listed (attribute = "H").
frNotRecursiveThe iteration is non-recursive. Subdirectories are ignored.
frRecursive
(Default value)
The iteration is recursive. Subdirectories are automatically taken into account.
fUnicodePath<Result> will be a string in Unicode format.

PHP This parameter is ignored.
WINDEVWEBDEV - Server codeReports and QueriesAndroidAndroid Widget iPhone/iPadJavaUser code (UMC)PHPAjax

Listing the files found in a directory by calling a procedure for each file Hide the details

<Result> = fListFile(<Path and generic name of files> , <WLanguage procedure> [, <Pointer> [, <Options>]])
<Result>: Integer
Number of listed files.
<Path and generic name of files>: Character string
Path and generic name of files to list. Generic characters (* and?) are allowed. Special cases:
  • if directory and drive not specified: the search path is built up from the current drive and the current directory for that drive.
  • if the drive is not specified but the directory is: the search path is formed from the current drive and the directory passed as a parameter.
  • if the drive is specified while the directory is not specified, the search path is built from the specified drive and from the current directory for this drive.
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 installation directory or one of its subdirectories, as well as to the external memory (SDCard).
iPhone/iPad 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 or iPad, an application has the rights to write to its installation directory or one of its subdirectories
<WLanguage procedure>: Procedure name
Name of the WLanguage procedure ("callback") called for each listed file. This procedure is used to handle the current file. For more details on this procedure, see Parameters of the procedure used by fListFile.
PHP The name of the procedure must correspond to a character string in quotes.
<Pointer>: Optional integer
Pointer passed to <WLanguage procedure>.
PHP Parameter passed to the function. This parameter is not necessarily an integer (it can be a string, ...).
<Options>: Optional Integer constant (or combination of constants)
Type of iteration performed for the directory files:
fdInterruptibleThe iteration can be interrupted by pressing ESC.
WEBDEV - Server codeLinux This constant has no effect.
frNotRecursiveThe iteration is non-recursive. Subdirectories are ignored.
frRecursive
(Default value)
The iteration is recursive. Subdirectories are automatically taken into account.
fUnicodePath<Result> will be a string in Unicode format.
PHP This parameter is ignored. The iteration is non-recursive and cannot be interrupted.
Remarks

Handling errors

Caution: fListFile does not return an error code.. To determine if this function has generated an error, use ErrorInfo with the errMessage constant.
WINDEVWEBDEV - Server codeReports and QueriesAndroidAndroid Widget iPhone/iPadJavaUser code (UMC)Ajax

Listing the subdirectories of a directory

To list the subdirectories of a directory, use fListDirectory.
Tip: It's also possible to list directories within a directory with the function fListFile.
Example:
fListFile("c:\temp\anim\.", proc) 
// Ne pas oublier le '.' à la fin de la chaîne pour identifier les répertoires
PROCEDURE proc(Rep, fichier, nChange, ptr) 
Trace(Rep)
Related Examples:
The fListFile function Unit examples (WINDEV): The fListFile function
[ + ] Using fListFile and its syntax that directly returns the list of files/directories found in string format.
Component: wd300std.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/24/2024

Send a report | Local help