IdFTP performance issue when Parsing all the files in a directory and subdirectories
<p>I need to parse every single file in a directory including the files in sub directories and sub sub directories and ...<br>
<strong>I have already successfully done this using the code below :</strong>  </p>

<pre><code>class function TATDFTPUtility.findAllDirectoryFiles(var ftpClient: TIdFTP; directory: String; deepness: Integer = 0): TidFTPListItems;
var
  I: Integer;
  localDirectoryListing: TIdFTPListItems;
  baseDirectory: string;
begin
  Result := TIdFTPListItems.Create;
  *// this function uses ftpClient.ChangeDirUp until it reaches the '' directory*
  changeUpToDirectory(ftpClient, '');
  try
    ftpClient.ChangeDir(directory);
    ftpClient.List;
    Result.Assign(ftpClient.DirectoryListing);
    localDirectoryListing := Result;
    baseDirectory := ftpClient.RetrieveCurrentDir;
    for I := 0 to localDirectoryListing.Count - 1 do
    begin
      if (localDirectoryListing.Items[i].ItemType = ditDirectory) then
      begin
        result := addTwoFTPListItems(result, findAllDirectoryFiles(ftpClient, baseDirectory + '/' + localDirectoryListing.Items[i].FileName));
      end;
    end;
  except
  end;
end;

class function TATDFTPUtility.addTwoFTPListItems(listA: TIdFTPListItems; listB: TIdFTPListItems): TidFTPListItems;
var
  i: integer;
begin
  Result := listA;
  for I := 0 to listB.Count - 1 do
  begin
    with Result.Add do
    begin
      Data := listB.Items[i].data;
      Size := listB.Items[i].Size;
      ModifiedDate := listB.Items[i].ModifiedDate;
      LocalFileName := listB.Items[i].LocalFileName;
      FileName := listB.Items[i].FileName;
      ItemType := listB.Items[i].ItemType;
      SizeAvail := listB.Items[i].SizeAvail;
      ModifiedAvail := listB.Items[i].ModifiedAvail;
      PermissionDisplay := listB.Items[i].PermissionDisplay;
    end;
  end;
end;
</code></pre>

<p>Now the problem is that <strong>this takes about 15-20 minutes !!!</strong>
<strong>Is there a more efficient way ?</strong><br>
<strong>Here is a few fact about this particular case :</strong><br>
1- After i ran the program it found about 12000 files with almost 100-200 directories but the highest deepness was about 7<br>
2- I only need to parse and i do not need to download or upload anything<br>
3- The reason i have used an exception is because inside the FTP there are a few folder which i do not have access and this causes an <code>access violation</code> Error in <code>IdFTP</code> and i used <code>try...except</code> to ignore any directory which can not be accessed.</p>