WebFtpFindNextFile Function

Action

Continues a file search started as a result of a preceding call to WebFtpFindFirstFile.

Include file

WebAPI.bdh

Syntax

WebFtpFindNextFile( in  hFtp       : number, 
                    out sFile      : string, 
                    in  nMaxFile   : number optional, 
                    out nAttribute : number optional): 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. A successful call to WebFtpFindFirstFile has to be completed before WebFtpFindNextFile can be used.
sFile Parameter that receives the name of the file or directory
nMaxFile Optional: Parameter that specifies the maximum length of the string to put into sFile
nAttribute

Optional: Parameter that receives one or more of the following attribute flags:

  • WEB_FTP_FA_READONLY

  • WEB_FTP_FA_HIDDEN

  • WEB_FTP_FA_SYSTEM

  • WEB_FTP_FA_DIRECTORY

  • WEB_FTP_FA_ARCHIVE

  • WEB_FTP_FA_NORMAL

  • WEB_FTP_FA_TEMPORARY

  • WEB_FTP_FA_COMPRESSED

  • WEB_FTP_FA_NO_MORE_FILES. Signals end of directory listing

Note: If there are no more files to enumerate, WebFtpFindNextFile returns false and sets the variable to WEB_FTP_FA_NO_MORE_FILES.

Example

dcltrans 
  transaction TWebFtpListDir 
  var
    hFtp       : number;
    sFileName  : string(MAX_PATH);
    nAttribute : number;
    nFiles     : number;
    bOk        : boolean; 
  begin
    WebFtpConnect(hFtp, "standardhost", WEB_PORT_FTP, "", "");
    nFiles := 0;
 
    // Custom directory list
    bOk := WebFtpFindFirstFile(hFtp, "", sFileName,
                               MAX_PATH, nAttribute); 
    while bOk do 
      Print(sFileName + " " + nAttribute); 
      nFiles++;
      bOk := WebFtpFindNextFile(hFtp, sFileName,
                                MAX_PATH, nAttribute); 
    end;

    if nAttribute = WEB_FTP_FA_NO_MORE_FILES then 
      Print(string(nFiles) + " files found"); 
    else 
      Print("Error retrieving directory information!"); 
    end;
 
    // The following command does the same
    WebFtpListDirectory(hFtp, "");
    WebFtpShutdown(hFtp); 
  end TWebFtpListDir;

SilkEssential sample

Ftp.sep