ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Communication / FTP functions
  • Procedure that handles each listed file
  • Timeout
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
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 SaaS
A new syntax for manipulating variables of type ftpConnection is available from WINDEV Suite SaaS 2025 - Update 2.
Reports and Queries
// Connection using a connection ID
// Connection to an FTP site
nConnection is int
nConnection = FTPConnect("ftp.cdrom.com")

nFile is int // Number of files in the directory
nJPG is int		// Number of .JPG files
nJPG = 0

// List ".JPG" files in the current directory
nFile = FTPListFile(nConnection, "", FTPListFile_Callback, ftpFile, nJPG)
Info("There are" + nJPG + ".JPG files in" + nFile + "listed files")
New in SaaS
// Connection using an ftpConnectionvariable
MyFTPConnection is ftpConnection
MyFTPConnection.Server = "ftp.cdrom.com"
FTPConnect(MyFTPConnection)

nFile is int // Number of files in the directory
nJPG is int		// Number of .JPG files
nJPG = 0

// List ".JPG" files in the current directory
nFile = FTPListFile(MyFTPConnection, "", FTPListFile_Callback, ftpFile, nJPG)
Info("There are" + nJPG + ".JPG files in" + nFile + "listed files")
// Procedure called by FTPListFile
// For each file found, the FTPListFile_Callback procedure 
// allows counting the number of files with ".JPG" extension.
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:
ftpDirectorySearches for directories only.
ftpFileSearches 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

For more details on the parameters of <WLanguage procedure>, see Parameters of the procedure used by FTPListFile.
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:
Related Examples:
The FTP functions 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
Component: wd300com.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
sDate format
The callback parameter for sDate appears to be a big interger string value.
fDate returns a YYYYMMDD format string
How can the sDate format be converted to match fDate?
ClaudeHullq
07 Aug. 2022

Last update: 05/05/2025

Send a report | Local help