PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Managing 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/iPadApple WatchUniversal Windows 10 AppWindows Mobile
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. See Native 64-bit and native 32-bit for more details.
Versions 18 and later
Stored procedures This function is now available in the code of stored procedures.
New in version 18
Stored procedures This function is now available in the code of stored procedures.
Stored procedures This function is now available in the code of stored procedures.
PHPAjax
AFile, ResFileList are strings
// Lists the ".BMP" files found in "C:\MyDocuments".
// The browse is also performed in the sub-directories 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
WEBDEV - Server codePHPAjax
// 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 can return files whose short name corresponds to the filter used (while the long name does not correspond to this filter).
<Path and generic name of files>: Character string (with quotes)
Path and generic name of files to list. The 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 in 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.
Versions 15 and later
WindowsLinux This parameter can be in Ansi or Unicode format.
New in version 15
WindowsLinux This parameter can be in Ansi or Unicode format.
WindowsLinux This parameter can be in Ansi or Unicode format.
<Options>: Combination of Integer constants
Option used to define the information returned as well as the type of browse performed for the directory files:
Versions 15 and later
fPathUNICODE
New in version 15
fPathUNICODE
fPathUNICODE
<Result> will be a string in Unicode format.
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 browse can be interrupted by pressing the ESC key. The function will return the name of the listed files until the interruption.
WEBDEV - Server codeLinux This constant has no effect in Windows Phone and Windows Store apps.
frNotRecursiveThe browse is a non-recursive browse. Subdirectories are ignored.
frRecursive
(Default value)
The browse is a recursive browse. The sub-directories are automatically taken into account.
frNoHiddenFileIf the frFullInformation constant is used, the hidden files are not listed (attribute = "H").
frNoHiddenDirectoryIf the frFullInformation constant is used, the hidden directories are not listed (attribute = "H").

PHP This parameter is ignored.
WEBDEV - Server codePHPAjax

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 (with quotes)
Path and generic name of files to list. The 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 in 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.
<WLanguage procedure>: Procedure name
Name of WLanguage procedure ("callback" procedure) that will be 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 browse performed for the directory files:
Versions 15 and later
fPathUNICODE
New in version 15
fPathUNICODE
fPathUNICODE
<Result> will be a string in Unicode format.
fdInterruptibleThe browse can be interrupted by pressing the ESC key.
WEBDEV - Server codeLinux This constant has no effect.
frNotRecursiveThe browse is a non-recursive browse. Subdirectories are ignored.
frRecursive
(Default value)
The browse is a recursive browse. The sub-directories are automatically taken into account.
PHP This parameter is ignored. The browse is a non-recursive browse and it cannot be interrupted.
Remarks

Managing errors

Caution: fListFile returns no error code. To find out whether an error was generated by this function, use ErrorInfo with the constant errMessage.
WEBDEV - Server codeAjax

Listing the subdirectories of a directory

To list the subdirectories of a directory, use fListDirectory.
Tip: fListFile can also be used to list the sub-directories 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)
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 : wd250std.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Video FlistFile
https://youtu.be/SE--Bx9Gq40
https://windevdesenvolvimento.blogspot.com/2019/09/dicas-2284-windev-webdev-mobile.html
//PROCEDURE LISTA_DIRETORIO()
s_ARQUIVOS_TODOS is string=fListDirectory(EDT_DIRETORIO)
s_ARQUIVO_INDIVIDUAL is string=""
TVT_DIRETORIO.DeleteAll()
FOR EACH STRING s_ARQUIVO_INDIVIDUAL OF s_ARQUIVOS_TODOS SEPARATED BY CR
n_POSICAO is int=TVT_DIRETORIO.AddLine() TVT_DIRETORIO.COL_01_DIRETORIO[n_POSICAO]=s_ARQUIVO_INDIVIDUAL
TVT_DIRETORIO[n_POSICAO]..AddChildDelayed=LISTA_SUB_DIRETORIO_1
END
LISTA_ARQUIVOS()
//
//PROCEDURE LISTA_ARQUIVOS()
TableDeleteAll(TABLE_ARQUIVOS)
s_ARQUIVOS_INDIVIDUAIS is string=fListFile(TVT_DIRETORIO.COL_01_DIRETORIO+"\*.*")
FOR EACH STRING sARQUIVO_ OF s_ARQUIVOS_INDIVIDUAIS SEPARATED BY CR
nPOSICAO is int=TABLE_ARQUIVOS.AddLine()
TABLE_ARQUIVOS[nPOSICAO].COL_ARQUIVO=sARQUIVO_
END
amarildo
11 Sep. 2019