WebFtpGetFile Function

Action

Retrieves a file from the FTP server.

Include file

WebAPI.bdh

Syntax

WebFtpGetFile( in hFtp            : number, 
               in sRemoteFile     : string, 
               in bBinaryTransfer : boolean ): boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
hFtp Valid handle to an FTP session. This handle must have been returned from a previous call to WebFtpConnect.
sRemoteFile String that contains the name of the file to retrieve from the remote system. Can be either partially or fully qualified file name relative to the current directory. A backslash (\) or forward slash (/) can be used as the directory separator for either name. WebFtpGetFile translates the directory name separators to the appropriate characters before they are used.
bBinaryTransfer

If this parameter is set to true, WebGetFile transfers the file using FTP's Image (Type I) transfer method. The file is transferred exactly as it exists with no changes. This is the default transfer method.

If this parameter is set to false, FTP's ASCII (Type A) transfer method is used. Control and formatting information is converted to local equivalents.

注: The file is only read from the remote host, but not stored on the local computer. Use the functions WebFtpOpenFile, WebFtpReadFile, WebFtpWriteFile and WebFtpCloseFile to exchange files between the local and the remote host.

Example

// Gets a file from the FTP server. 
dcltrans 
  transaction TWebFtpDir 
  var
    hFtp: number; 
  begin
    WebFtpConnect(hFtp, "standardhost", WEB_PORT_FTP, 
                 "anonymous", "mymail@address.com"); 
    WebFtpGetFile(hFtp, "test_file.txt", FALSE);
    WebFtpShutdown(hFtp); 
  end TWebFtpDir;

SilkEssential sample

Ftp.sep