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
Universal Windows 10 App This function is now available in Windows Store apps mode.
Stored procedures This function is now available in the code of stored procedures.
New in version 18
Universal Windows 10 App This function is now available in Windows Store apps mode.
Stored procedures This function is now available in the code of stored procedures.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Stored procedures This function is now available in the code of stored procedures.
Versions 21 and later
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
New in version 21
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
WINDEVUser code (UMC)
AFile, ResFileList are strings
// Lists the ".BMP" files found in "C:\MyDocuments".
// The browse 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
WINDEVJavaUser code (UMC)
// 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.
frNotRecursiveThe browse is a non-recursive browse. Subdirectories are ignored.
frRecursive
(Default value)
The browse is recursive. Subdirectories 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").

WINDEVJavaUser code (UMC)

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.
<Pointer>: Optional integer
Pointer passed to <WLanguage procedure>.
<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.
Linux This constant has no effect.
frNotRecursiveThe browse is a non-recursive browse. Subdirectories are ignored.
frRecursive
(Default value)
The browse is recursive. Subdirectories are automatically taken into account.
Remarks

Managing errors

Caution: fListFile returns no error code. To find out if this function has generated an error, use ErrorInfo with the errMessage constant.
WINDEVJavaUser code (UMC)

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)
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