PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
  • Procedure that handles each listed file
  • Transfer timeout
  • Required permissions
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
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 searched in the given directory. 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.
WINDEVWEBDEV - Server codeReports and QueriesAndroidAndroid Widget JavaUser code (UMC)Ajax
// Lists the .BMP files found in "/Documents" on the FTP server.
// The FTPListFile_Callback procedure returns the number of read-only files.
ResFileList = FTPListFile(7, "/Documents/*.BMP", FTPListFile_Callback)
WINDEVWEBDEV - Server codeReports and QueriesJavaUser code (UMC)Ajax
// Connection to an FTP site
nConnection is int
nConnection = FTPConnect("ftp.cdrom.com")
 
nFile is int  // Number of files found 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")
 
 
// Procedure called by FTPListFile
// For each file found, the FTPListFile_Callback procedure
// allows counting the number of files with ".JPG" extension.
INTERNAL PROCÉDURE FTPListFile_Callback(Name, nSize, sAttribute, sDate, sTime, nParam)
IF Right(Name, 4) ~= ".JPG" THEN
nParam++
END
RETURN True
END
Syntax
<Result> = FTPListFile(<Connection identifier> , <Path and generic name of files> , <WLanguage procedure> [, <Files/Directories> [, <Parameter>]])
<Result>: Integer
  • Number of listed files,
  • 0 (if an error occurred). To determine if this function has generated an error, use ErrorInfo 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
Path and generic name of files (or directories) to list. 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>".
<WLanguage procedure>: Procedure name
Name of the WLanguage procedure ("callback") called for each listed file. This procedure is used to handle the current file.
To force the browse operation to stop, the procedure must return False and to continue the browse operation, the procedure MUST return True.
For more details on this procedure, see Parameters of the procedure used by FTPListFile.
<Files/Directories>: Optional constant (or combination of constants)
Specifies the searched elements:
ftpDirectoryThe search is performed on the directories.
ftpFileThe search is performed on the files only.
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 <Procedure name>.
Remarks

Procedure that handles each listed file

For more details on the parameters of <WLanguage procedure>, see Parameters of the procedure used by FTPListFile.
Caution: 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 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 <WLanguage procedure>.

Transfer timeout

By default, all the FTP functions fail if the FTP server does not respond within 20 seconds. This timeout can be modified with FTPConnect when connecting to the FTP server.
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 (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: wd270com.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