PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US

  • Procedure for managing each listed directory (syntax 2 only)
  • Interrupting fListDirectory (syntax 2)
  • Managing the errors
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 subdirectories of a given directory and returns the full paths of listed subdirectories.
Other user: For each directory found, fListDirectory can automatically call a special procedure written in WLanguage. This procedure is used to handle the current directory. In this case, fListDirectory returns the number of listed directories.
Versions 15 and later
Android This function is now available for Android applications.
New in version 15
Android This function is now available for Android applications.
Android This function is now available for Android applications.
Versions 16 and later
Universal Windows 10 App This function is now available for Windows Phone applications.
New in version 16
Universal Windows 10 App This function is now available for Windows Phone applications.
Universal Windows 10 App This function is now available for Windows Phone applications.
Versions 17 and later
iPhone/iPad This function is now available for iPhone/iPad applications.
New in version 17
iPhone/iPad This function is now available for iPhone/iPad applications.
iPhone/iPad This function is now available for iPhone/iPad applications.
Versions 18 and later
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
New in version 18
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
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.
WINDEVWEBDEV - Server codeReports and QueriesWindows MobileJavaPHPAjaxUser code (UMC)
ADirectory, ResListDirectory are strings
DirectoryToList is string
DirectoryToList = "C:\MyDocuments"
// Windows Mobile: DirectoryToList = "\MyDocuments"
 
// List all the directories present in DirectoryToList.
ResListDirectory = fListDirectory(DirectoryToList)
// For each directory found
FOR EACH STRING ADirectory OF ResListDirectory SEPARATED BY CR
// Add the directory into TABLE_DirTable
TableAdd(TABLE_DirTable, ADirectory)
END
WINDEVWEBDEV - Server codeReports and QueriesWindows MobileJavaPHPAjaxUser code (UMC)
DirectoryToList = "C:\MyDocuments"
// Windows Mobile: DirectoryToList = "\MyDocuments"
 
 
// List the directories present in DirectoryToList.
// The DirectoryAttribute procedure returns the number of read-only directories.
ResListDirectory = fListDirectory(DirectoryToList, "DirectoryAttribute")
Syntax

Listing the subdirectories of a directory Hide the details

<Result> = fListDirectory(<Path of initial directory> [, <Options>])
<Result>: Character string
Name of listed directories, separated by CR characters (Carriage Return).
<Path of initial directory>: Character string (with quotes)
Path of directory from which the subdirectories will be sought.
Versions 15 and later
WindowsLinux This parameter can be in Ansi or Unicode format.
AndroidAndroid Widget This parameter can correspond to a full path or to a relative path in relation 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 has the rights to write into its setup directory or into one of its subdirectories, as well as onto the external memory (SDCard).
New in version 15
WindowsLinux This parameter can be in Ansi or Unicode format.
AndroidAndroid Widget This parameter can correspond to a full path or to a relative path in relation 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 has the rights to write into its setup directory or into one of its subdirectories, as well as onto the external memory (SDCard).
WindowsLinux This parameter can be in Ansi or Unicode format.
AndroidAndroid Widget This parameter can correspond to a full path or to a relative path in relation 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 has the rights to write into its setup directory or into one of its subdirectories, as well as onto the external memory (SDCard).
Versions 16 and later
Universal Windows 10 App The directory path corresponds to a relative path in relation to the current directory. The current directory corresponds to the data directory of application.
Reminder: Only the directories found in the data directory associated with the application can be used.
New in version 16
Universal Windows 10 App The directory path corresponds to a relative path in relation to the current directory. The current directory corresponds to the data directory of application.
Reminder: Only the directories found in the data directory associated with the application can be used.
Universal Windows 10 App The directory path corresponds to a relative path in relation to the current directory. The current directory corresponds to the data directory of application.
Reminder: Only the directories found in the data directory associated with the application can be used.
Versions 17 and later
iPhone/iPad This parameter can correspond to a full path or to a relative path in relation 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.
New in version 17
iPhone/iPad This parameter can correspond to a full path or to a relative path in relation 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.
iPhone/iPad This parameter can correspond to a full path or to a relative path in relation 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>: Integer constant or combination of constants (optional)
Options that can be taken into account:
fPathUNICODE
Versions 15 and later
<Result> will be a string in Unicode format.
Windows Mobile This constant is ignored because <Result> is always a Unicode string.
New in version 15
<Result> will be a string in Unicode format.
Windows Mobile This constant is ignored because <Result> is always a Unicode string.
<Result> will be a string in Unicode format.
Windows Mobile This constant is ignored because <Result> is always a Unicode string.
Versions 16 and later
Universal Windows 10 App This constant is ignored.
New in version 16
Universal Windows 10 App This constant is ignored.
Universal Windows 10 App This constant is ignored.
fdInterruptibleThe browse can be interrupted by pressing the ESC key. The function will return the name of directories listed until the interruption.
WEBDEV - Server codeWindows MobileUniversal Windows 10 App This constant has no effect.
frNotRecursiveThe browse is a non-recursive browse. Subdirectories are ignored.
frRecursive
(Default value)
The browse is a recursive browse. Subdirectories are automatically taken into account.
WINDEVWEBDEV - Server codeReports and QueriesAndroidAndroid Widget iPhone/iPadWindows MobileJavaPHPAjaxUser code (UMC)

Listing the subdirectories of a directory by calling a procedure for each directory Hide the details

<Result> = fListDirectory(<Path of initial directory> , <Procedure name> [, <Pointer> [, <Options>]])
<Result>: Integer
Number of listed directories.
<Path of initial directory>: Character string (with quotes)
Path of directory from which the subdirectories will be sought.
Versions 15 and later
WindowsLinux This parameter can be in Ansi or Unicode format.
AndroidAndroid Widget This parameter can correspond to a full path or to a relative path in relation 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 has the rights to write into its setup directory or into one of its subdirectories, as well as onto the external memory (SDCard).
New in version 15
WindowsLinux This parameter can be in Ansi or Unicode format.
AndroidAndroid Widget This parameter can correspond to a full path or to a relative path in relation 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 has the rights to write into its setup directory or into one of its subdirectories, as well as onto the external memory (SDCard).
WindowsLinux This parameter can be in Ansi or Unicode format.
AndroidAndroid Widget This parameter can correspond to a full path or to a relative path in relation 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 has the rights to write into its setup directory or into one of its subdirectories, as well as onto the external memory (SDCard).
Versions 17 and later
iPhone/iPad This parameter can correspond to a full path or to a relative path in relation 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.
New in version 17
iPhone/iPad This parameter can correspond to a full path or to a relative path in relation 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.
iPhone/iPad This parameter can correspond to a full path or to a relative path in relation 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.
<Procedure name>: Character string (with or without quotes)
Name of WLanguage procedure ("callback") called for each listed directory. This procedure is used to handle the current directory. This procedure has the following format:
PROCEDURE <Procedure name> (<Path>, <Directory name>, <Change>,
<Procedure pointer>)
The parameters of this procedure are optional.
There is no need to pass parameters to this procedure. Indeed, these parameters are automatically filled whenever a directory is processed.
<Pointer>: Optional integer
Pointer passed to <Procedure name>.
<Options>: Combination of Integer constants
Type of browse performed for the directory files:
fPathUNICODE
Versions 15 and later
<Result> will be a string in Unicode format.
Windows Mobile This constant is ignored because <Result> is always a Unicode string.
New in version 15
<Result> will be a string in Unicode format.
Windows Mobile This constant is ignored because <Result> is always a Unicode string.
<Result> will be a string in Unicode format.
Windows Mobile This constant is ignored because <Result> is always a Unicode string.
fdInterruptibleThe browse can be interrupted by pressing the ESC key. The function will return the number of directories listed until the interruption.
WEBDEV - Server codeWindows Mobile This constant has no effect.
frNotRecursiveThe browse is a non-recursive browse. Subdirectories are ignored.
frRecursive
(Default value)
The browse is a recursive browse. Subdirectories are automatically taken into account.
Remarks

Procedure for managing each listed directory (syntax 2 only)

For each directory found, fListDirectory automatically calls the procedure <Procedure name>. This procedure is a local or global procedure.
To create this procedure:
  1. Create a global procedure ("Insert .. New global procedure" in the code editor).Create a global procedure (from the code editor: on the "Code" pane, in the "Procedures" group, expand "New" and select "New global procedure").
  2. Fill the procedure declaration as follows:
    PROCEDURE <Procedure name> (<Path>, <Directory name>, <Change>,
    <Procedure pointer>)
    • <Path> is the directory path used (it always ends with a "\" character; "C:\MyFiles\" for example).
    • <Directory name> is a character string containing the name of directory found.
    • <Change> is a constant set to:
      • flChangeDir when the directory is the first directory listed in a subdirectory of <Path> (a change of directory occurred),
      • fDirectory in all the other cases.

        The different values that can be taken by <Change> are as follows:
        Current directory<Change>
        Dir\Directory 1flDirectory
        Dir\Directory nflDirectory
        Dir\SubDir 1\Directory 1flChangeDir
        Dir\SubDir 1\Directory mflDirectory
        Dir\SubDir 2\Directory 1flChangeDir
        Sub\SubDir 2\Directory xflDirectory
  • <Procedure pointer> is an integer whose value is the one passed to the <Pointer> parameter of fListDirectory. If <Pointer> is not specified, <Pointer> is set to 0.
To retrieve the value of <Procedure pointer>, assign its value to the value of <Pointer> in the procedure with Transfer (see the detailed example at the top of the page).
Note: The parameters of this procedure are optional: you have the ability to specify the name and the path for example.

Interrupting fListDirectory (syntax 2)

As long as there are directories to browse, fListDirectory cannot be interrupted. To force the interruption of the browse, use the following code line in the <Procedure name> procedure:
RESULT False
In this case, fListDirectory returns the number of directories browsed until the call to "Result False".
In any other case (to continue the browse), <Procedure name> MUST return True.
An error is generated if <Procedure name> returns no value (neither True nor False).

Managing the errors

Caution: fListDirectory returns no error code. To find out whether an error was generated by this function, use ErrorInfo with the constant errMessage.
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 : wd240std.dll
Minimum required version
  • Version 10
This page is also available for…
Comments
Video fListDiretory
https://youtu.be/tpuThghZguE
https://windevdesenvolvimento.blogspot.com/2019/09/dicas-2282-windev-webdev-mobile.html
// BTN_DIRETORIO_LISTA
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
nPOSICAO is int=TVT_DIRETORIO.AddLine()
TVT_DIRETORIO.COL_01_DIRETORIO[nPOSICAO]=s_arquivo_individual
END
amarildo
Sep. 10 2019
Exemplo fListDirectory
_nome_diretorio, _lista_diretorios are strings
IF YesNo("Somente Diretorios") THEN
_lista_diretorios=fListDirectory("D:\amarildo",frNotRecursive)
ELSE
_lista_diretorios=fListDirectory("D:\amarildo")
END
TableDeleteAll(TABLE_Diretorio)
FOR EACH STRING _nome_diretorio OF _lista_diretorios SEPARATED BY CR
TableAdd(TABLE_Diretorio,_nome_diretorio)
END

//Blog com Video e Exemplo
http://windevdesenvolvimento.blogspot.com.br/2016/09/curso-windev-arquivos-017-arquivos.html
https://www.youtube.com/watch?v=qCiBXw6xvqw
De matos AMARILDO
Sep. 10 2016