PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Procedure that handles each listed file
  • Interrupting FTPListFile
  • Time-out for transfer
  • Internet browser
  • Required permissions
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 (and/or the directories) found in a directory of an FTP server and returns the number of listed files (and/or directories)
The listed files are sought from the given directory (in all sub-directories). For each found file, FTPListFile automatically calls a specific procedure. This procedure is used to handle the current file. This procedure must return a result (True to continue to list the directories and/or the files, False to stop).
Caution: This function is not recursive. The search is performed in the specified directory, while ignoring the sub-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 18 and later
Android Widget This function is now available in Android Widget mode.
WINDEVLinux This function is now available for the WINDEV applications in Linux.
WEBDEV - Server codeLinux This function is now available for the WEBDEV sites in Linux.
iPhone/iPad This function is now available for the iPhone/iPad applications.
New in version 18
Android Widget This function is now available in Android Widget mode.
WINDEVLinux This function is now available for the WINDEV applications in Linux.
WEBDEV - Server codeLinux This function is now available for the WEBDEV sites in Linux.
iPhone/iPad This function is now available for the iPhone/iPad applications.
Android Widget This function is now available in Android Widget mode.
WINDEVLinux This function is now available for the WINDEV applications in Linux.
WEBDEV - Server codeLinux This function is now available for the WEBDEV sites in Linux.
iPhone/iPad This function is now available for the iPhone/iPad applications.
WINDEVWEBDEV - Server codeReports and QueriesAndroidAndroid Widget Windows MobileJavaAjaxUser code (UMC)
// Lists the .BMP files found in "/Documents" on the FTP server.
// The FileAttribute procedure returns the number of read-only files.
ResFileList = FTPListFile(7, "/Documents/*.BMP", "FileAttribute")
Syntax
<Result> = FTPListFile(<Connection Identifier> , <Path and Generic Name of Files> , <Procedure Name> [, <Files/Directories> [, <Parameter>]])
<Result>: Integer
  • Number of listed files,
  • 0 (if an error occurred). To find out whether an error was generated by this function, use ErrorInfo associated with the errMessage constant.
<Connection Identifier>: Integer
Connection identifier, returned by FTPConnect.
PHP This parameter is a Variant parameter.
<Path and Generic Name of Files>: Character string (with quotes)
Path and generic name of files (or directories) to list. The generic characters (* and?) are allowed. The different path sections are separated by "slashes" ("/").
If the path has the following format "/<DirectoryName>/<FileName>": The search path is "/<Directory name>/<File name>".
If the path has the following format "<DirectoryName>/<FileName>": The search path is "/<Current server directory>/<Directory name>/<File name>".
<Procedure Name>: Character string (with or without quotes)
Name of procedure called for each listed file ("callback"). This procedure is used to handle the current file. This procedure must return a result.
To force the browse operation to stop, the procedure must return False and to continue the browse operation, the procedure MUST return True.
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 file is processed.
<Files/Directories>: Optional constant (or combination of constants)
Specifies the sought elements:
ftpFileThe search is performed on the files only.
ftpDirectoryThe search is performed on the directories.
By default, this parameter is set to ftpFile+ftpDirectory: the search is performed on the files and directories.
<Parameter>: Type corresponding to the value passed (optional)
Parameter passed to the <Procedure Name> procedure.
Remarks

Procedure that handles each listed file

For each file found, FTPListFile automatically calls the <Procedure Name> procedure. This procedure is declared as follows:
PROCEDURE <Procedure Name>(<File>[, <Size> [, <Attribute> ...
[, , <Date> [. <Time> [, <Procedure Parameter>]]]]])
  • <File>: name of file or directory used.
  • <Size>: optional integer corresponding to the size of file found (in bytes). This parameter must be ignored for a directory.
  • <Attribute>: optional character string describing the attributes of file or directory found. The format used is identical to the one of FTPAttribute.
  • <Date>: optional character string corresponding to the modification date of file (or directory) found. The format used is "YYYYMMDD".
  • <Time>: optional character string corresponding to the modification time of file (or directory) found. The format used is "HHMMSS".
  • <Procedure parameter>: corresponds to the value passed to the <Parameter> of FTPListFile. If <Parameter> is not specified, <Procedure parameter> is set to 0.
Caution: In the <Procedure Name> procedure:
  • no FTP function that uses the same connection as the one used by FTPListFile must be called.
  • you can retrieve the properties (name, size, attributes, dates and times) of the file listed by FTPName, FTPSize, FTPAttribute, FTPDate and FTPTime. However, this solution takes a lot of time: it requires an additional request to the FTP server. Therefore, it is easier to directly read the optional parameters passed to the <Procedure Name> procedure.

Interrupting FTPListFile

FTPListFile cannot be interrupted as long as files must still be browsed. To force the interruption of the browse, use the following code line in the <Procedure Name> procedure:
RESULT False
In this case, FTPListFile returns the number of files 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).

Time-out for transfer

By default, all the FTP functions fail if the FTP server does not respond within 20 seconds. This time-out can be modified by FTPConnect when connecting to the FTP server.
WINDEVWEBDEV - Server codeReports and QueriesWindows MobileAjaxUser code (UMC)

Internet browser

FTPListFile requires Internet Explorer version 3 or later.
If a problem occurs, we recommend that you run a test with the browser by directly passing a link such as "ftp://server/...". If a problem occurs with Internet Explorer (with a UNIX server for example), use FTPCommand directly.
AndroidAndroid Widget

Required permissions

The call to this function modifies the permissions required by the application.
Required permission : INTERNET
This permission allows the applications to open the network sockets.
Related Examples:
The FTP functions Unit examples (WEBDEV): The FTP functions
[ + ] This example presents the main FTP functions of WEBDEV and it allows you to:
- Connect to an FTP server
- List the files and directories found on the FTP server
- Retrieve the files found on the FTP server
- Disconnect from an FTP server
Components
WINDEVWEBDEV - Server codeReports and Queries wd230com.dll
Windows Mobile wp230com.dll
Java wd230java.jar
Linux wd230com.so
Android wd230android.jar
Minimum required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment