FTP - Getting a list of the files in a directory - Problem

Giganews Newsgroups
Subject: FTP - Getting a list of the files in a directory - Problem
Posted by:  G. Bradley MacDonald (bradley_AT_telus_DOT_net)
Date: 12/8/2004 2:22:33 AM

Hello

I am using Indy 9 with Delphi 6.  I am trying to get information about
the files stored on a FTP server.  Basically I have written a recursive
routine to go through the entire FTP server and get me the sizes of the
files.

I seems to work - with one problem.  I have encountered directories
where I get Zero records returned to the FDirectoryListing property. But
yet it returns the correct values for the other directories on the same
server.  Now the first thing I did was check permissions on the FTP
server (MS IIS) - and the user has full access.
Then I checked the results of a IDFTP.List - and I see all the files in
the list...  So after I do the LIST method - I normally see that the
count for both the string list and the FDirectoryListing property are
the same.  However, on some directories ... the StringList will show a
numberer (say 4) as its count (which is correct) - but the
FDirectoryListing shows its count as ZERO - which is wrong.

Any thoughts as to what might be causing the problem?
Any ideas where to look?

// snippet of Code that gets the information.

// Create the String List to hold the list of files in the directory
  DirList      := TStringList.Create;

  // Now jump to the correct directory - TreeBranch is the directory in
question
  If (Length(TreeBranch) > 0) then Begin
    TAFTPSiteList.FTPServer.ChangeDir(TreeBranch);
  End; // If

  // Load the files in the List
  // FTPServer is an instance of IDFTP
  TAFTPSiteList.FTPServer.List(DirList);
  ShowMessage('Dir: ' + DirList.Text
              + #10#13 + #10#13
              + '  Count: ' + IntToStr(DirList.Count));
  ShowMessage('DirListCount: ' + IntToStr
(TAFTPSiteList.FTPServer.DirectoryListing.Count));

Any thoughts as to what might be going wrong would be greatly
appreciated!!

G. Bradley MacDonald
bradley_AT_telus_DOT_net

Replies