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 sub-directories of a given directory and returns the list of sub-directories.
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 the Android applications.
New in version 15
Android This function is now available for the Android applications.
Android This function is now available for the Android applications.
Versions 16 and later
Universal Windows 10 App This function is now available for the Windows Phone applications.
New in version 16
Universal Windows 10 App This function is now available for the Windows Phone applications.
Universal Windows 10 App This function is now available for the Windows Phone applications.
Versions 17 and later
iPhone/iPad This function is now available for the iPhone/iPad applications.
New in version 17
iPhone/iPad This function is now available for the iPhone/iPad applications.
iPhone/iPad This function is now available for the 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 QueriesJavaPHPAjaxUser code (UMC)
ADirectory, ResListDirectory are strings
// Lists all the directories found in "C:\MyDocuments".
ResListDirectory = fListDirectory("C:\MyDocuments")
// For each directory found
FOR EACH STRING ADirectory OF ResListDirectory SEPARATED BY CR
// Add the directory into TABLE_DirTable
TableAdd(TABLE_DirTable, ADirectory)
END
Windows Mobile
ADirectory, ResListDirectory are strings
// Lists all the directories found in "\MyDocuments".
ResListDirectory = fListDirectory("\MyDocuments")
// 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 QueriesJavaPHPAjaxUser code (UMC)
// Lists the directories found in "C:\MyDocuments".
// The DirectoryAttribute procedure returns the number of read-only directories.
ResListDirectory = fListDirectory("C:\MyDocuments", "DirectoryAttribute")
Windows Mobile
// Lists the directories found in "\MyDocuments".
// The DirectoryAttribute procedure returns the number of read-only directories.
ResListFile = fListDirectory("\MyDocuments", "DirectoryAttribute")
Syntax

Listing the sub-directories 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 sub-directories 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 sub-directories, 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 sub-directories, 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 sub-directories, 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 sub-directories.
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 sub-directories.
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 sub-directories.
<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. The sub-directories are ignored.
frRecursive
(Default value)
The browse is a recursive browse. The sub-directories are automatically taken into account.
WINDEVWEBDEV - Server codeReports and QueriesAndroidAndroid Widget iPhone/iPadWindows MobileJavaPHPAjaxUser code (UMC)

Listing the sub-directories 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 sub-directories 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 sub-directories, 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 sub-directories, 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 sub-directories, 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 sub-directories.
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 sub-directories.
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 sub-directories.
<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 the <Procedure Name> procedure.
<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. The sub-directories are ignored.
frRecursive
(Default value)
The browse is a recursive browse. The sub-directories are automatically taken into account.
Remarks

Procedure for managing each listed directory (syntax 2 only)

For each directory found, fListDirectory automatically calls the <Procedure Name> procedure. 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 sub-directory 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>, the value of <Procedure Pointer> must be assigned to the value of <Pointer> in the procedure by 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)

fListDirectory cannot be interrupted as long as all directories have not been browsed. 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 associated with the errMessage constant.
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.
Components
WINDEVWEBDEV - Server codeReports and Queries wd230std.dll
Windows Mobile wp230std.dll
Java wd230java.jar
Linux wd230std.so
Android wd230android.jar
Minimum required version
  • Version 10
This page is also available for…
Comments
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