Class FTPClient() Professional

Class function of the FTPClient class


Instances of the FTPClient class are used to access an FTP server via the File Transfer Protocol. This communication protocol allows for exchanging the contents of arbitrary files between a client computer and a remote server in the Internet. A prerequisite for successfully using the FTPClient class is that Username and Password for accessing an FTP server are known. A connection to an FTP server fails without proper authentication.

Operations such as getting a file or changing the current directory can only be performed sequentially per session. Consequently, the corresponding methods are SYNC methods and hence are serialized between threads. If concurrent operations against the same FTP server are required in an application, a new connection must be initiated from another thread using a separate FTPClient object.

Class methods
Creates an instance of the FTPClient class.
Connects to the FTP server.
Disconnects from the FTP server.
File management
Removes a file from the FTP server.
Retrieves the contents of a file located on the FTP server.
Download a file from the FTP server.
Writes a character string into a file on the FTP server.
Upload a file to the FTP server.
Set the mode with which the transfer is performed.
Directory management
Create a directory on the FTP server.
Determine or change the current directory on the FTP server.
Fills an array with information about the files in a specified path.
Remove a directory on the FTP server.
Uploading and Downloading files
// The example demonstrates the programming pattern 
// for uploading or downloading files to/from 
// an FTP server. 

#pragma Library( "ASINet10.lib" ) 


   LOCAL cFtpServer := "" 
   LOCAL cUserName  := "my_Username" 
   LOCAL cPassword  := "my_password" 
   LOCAL oFtp, cContents 

   oFtp := FTPClient():new( cFtpServer, cUserName, cPassWord ) 

   IF .NOT. oFtp:connect() 
      ? "Unable to establish connection to:" , cFtpServer 

   cContents := Memoread( "c:\filename.txt" ) 

   // Uploading file contents 
   IF .NOT. oFtp:put( "ftp_dir\filename.txt", cContents ) 
      ? "Unable to transfer file contents" 
      // Downloading file contents 
      ? oFtp:get( "ftp_dir\filename.txt" ) 




If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.