PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN

  • Handling errors
  • Listing the subdirectories of a directory
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
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, fListFile 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.
Remark: In 64-bit Windows, the access to a system directory from a 32-bit executable can be performed in a directory that differs from the expected one. For more details, see Native 64-bit and native 32-bit.
WINDEVReports and QueriesUser code (UMC)PHPAjax
AFile, ResFileList are strings
// Lists the ".BMP" files found in "C:\MyDocuments".
// The iteration is also performed in the subdirectories and it can be interrupted.
ResFileList = fListFile("\MyDocuments\*.BMP", frRecursive + frInterruptible)
// For each file found
FOR EACH STRING AFile OF ResFileList SEPARATED BY CR
// Add the file into TABLE_FileTable
TableAdd(TABLE_FileTable, AFile)
END
WINDEVWEBDEV - Server codeReports and QueriesJavaUser code (UMC)PHPAjax
// Lists the ".BMP" files found in "C:\MyDocuments".
// The FileAttribute procedure returns the number of read-only files.
ResFileList = fListFile("C:\MyDocuments\*.BMP", "FileAttribute")
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).

Caution: The function returns the files with short or long names that match 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 the directory and the drive are not specified: the search path is built from the current drive and from the current directory for this drive.
  • if the drive is not specified while the directory is specified: the search path is built from the current drive and from the directory passed as 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 setup 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/iPad, an application has the rights to write into its setup directory or into 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:
<Full file name> + TAB + <Size in bytes> + TAB +
<Date of last modification> + TAB + <File attributes>
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.
fPathUNICODE<Result> will be a string in Unicode format.
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.

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 the directory and the drive are not specified: the search path is built from the current drive and from the current directory for this drive.
  • if the drive is not specified while the directory is specified: the search path is built from the current drive and from the directory passed as 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 setup 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/iPad, an application has the rights to write into its setup directory or into 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.
fPathUNICODE<Result> will be a string in Unicode format.
frNotRecursiveThe iteration is non-recursive. Subdirectories are ignored.
frRecursive
(Default value)
The iteration is recursive. Subdirectories are automatically taken into account.
PHP This parameter is ignored. The iteration is non-recursive and cannot be interrupted.
Remarks

Handling errors

Caution: fListFile returns no 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: fListFile can also be used to list the subdirectories of a directory.
Example:
fListFile("c:\temp\anim\.", proc)
// Don't forget the '.' at the end of string to identify the directories
PROCÉDURE proc(Dir, file, nChange, ptr)
Trace(Dir)
Component: wd280std.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment