|
|
|
|
|
- Procedure that handles each listed file
- Timeout
FTPListFile (Function) In french: FTPListeFichier Lists the directories or files in a directory located on an FTP server and returns the number of files and/or directories The listed files are searched in a given directory. For each file found, FTPListFile automatically calls a specific procedure. This procedure handles the current file. This procedure must return a result (True to continue to list the directories and/or the files, False to stop). Note: This function is not recursive. The search is started in the specified directory, without taking subdirectories into account. New in SaaSA new syntax for manipulating variables of type ftpConnection is available from WINDEV Suite SaaS 2025 - Update 2. New in SaaS
MyFTPConnection is ftpConnection
MyFTPConnection.Server = "ftp.cdrom.com"
FTPConnect(MyFTPConnection)
nFile is int
nJPG is int
nJPG = 0
nFile = FTPListFile(MyFTPConnection, "", FTPListFile_Callback, ftpFile, nJPG)
Info("There are" + nJPG + ".JPG files in" + nFile + "listed files")
INTERNAL PROCEDURE FTPListFile_Callback(Name, nSize, sAttribute, sDate, sTime, nParam)
IF Right(Name, 4) ~= ".JPG" THEN
nParam++
END
RETURN True
END
Syntax
<Result> = FTPListFile(<FTP connection> , <Path and generic name of files> , <WLanguage procedure> [, <Files/Directories> [, <Parameter>]])
<Result>: Integer - Number of listed files,
- 0 (if an error occurs). To determine if this function has generated an error, use ErrorInfo with the errMessage constant.
<FTP connection>: Integer or ftpConnection variable Name of the ftpConnection variable that describes the characteristics of the connection to the FTP server. Note: This variable type is only available from WINDEV Suite SaaS 2025 - Update 2. <Path and generic name of files>: Character string Path and generic name of files or directories to be listed. Generic characters (* and?) are allowed. The different parts of the path are separated by "slashes" ("/").If the path has the format "/<DirectoryName>/<FileName>", the search path will be "/<DirectoryName>/<FileName>". If the path has the format "<DirectoryName>/<FileName>", the search path will be "/<ServeurCurrentDirectory>/<DirectoryName>/<FileName>". <WLanguage procedure>: Procedure name Name of the WLanguage procedure ("callback") called for each listed file. This procedure handles the current file. The procedure must return False to stop iterating over the files and True to continue. For more details on this procedure, see Parameters of the procedure used by FTPListFile. <Files/Directories>: Optional constant (or combination of constants) Specifies the search elements:
| | ftpDirectory | Searches for directories only. | ftpFile | Searches for files only. | By default, this parameter is set to ftpFile+ftpDirectory. This means both files and directories are searched. <Parameter>: Type corresponding to the value passed (optional) Parameter passed to <WLanguage procedure>. Remarks Procedure that handles each listed file Note: In <WLanguage 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 is time-consuming, as it requires an additional request to the FTP server. Therefore, it is easier to directly read the optional parameters passed to the <WLanguage procedure>.
Timeout By default, all the FTP functions fail if the FTP server does not respond within 20 seconds. This time can be modified: - when connecting to the FTP server with FTPConnect (<Timeout> parameter).
New in SaaSwhen defining the parameters of the ftpConnection variable ( Timeout property). Note: This feature is only available from WINDEV Suite SaaS 2025 - Update 2.
Related Examples:
|
Unit examples (WINDEV): The FTP functions
[ + ] Using the main FTP functions of WINDEV: - Connect to a FTP server - List the files and directories found on the FTP server - Retrieve the files found on the FTP server - Disconnect from a FTP server
|
Business / UI classification: Business Logic
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|