WebFtpGetFileSize Function

Action

Retrieves the file size of a remote file, enumerated using WebFtpFindFirstFile/WebFtpFindNextFile functions.

Include file

WebAPI.bdh

Syntax

WebFtpGetFileSize( in  hFtp      : number, 
                   out fFileSize : float ): 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.
fFileSize Variable that receives the file size in bytes. This parameter is an 8 byte float which allows to cope with files greater than 4 GB.

Example

dcltrans 
  transaction TGetFileSize 
  var
    hFtp  : number;
    fFileSize : float;
    nDate     : number;
    nTime     : number;
    sFileName : string;
    sDateTime : string;

  begin
    WebFtpConnect(hFtp, "localhost", WEB_PORT_FTP, "user", "pass");
    WebFtpFindFirstFile(hFtp, "testfile.txt", sFileName); 
    WebFtpGetFileSize(hFtp, fFileSize); 
    Print("The file " + sFileName + " has " + fFileSize + " bytes."); 
    WebFtpGetFileTime(hFtp, nDate, nTime, WEB_FTP_FILETIME_MODIFIED);
    FormatDateTime(nDate, nTime, "%Y-%m-%d %H:%M:%S", sDateTime);
    Print(sFilename + " modified time is " + sDateTime);
    WebFtpShutdown(hFtp); 
  end TGetFileSize;