I am new to delphi, I need to write an ftp client program that will go through a text file with list of ftp addresses, and download the subfolders from an ftp site . I have successfully hooked to the server but got stuck on the download part. can someone please help me with the codes to insert in the download procedure
 procedure TCleint.btnConnectClick(Sender: TObject);
begin
    try
       if not IdFTP.Connected then
       begin
           IdFTP.Host := 'ftp server';
           IdFTP.Username := 'anonymous';
           IdFTP.Password := 'emailaddress';
           IdFTP.Port := 21;
           IdFTP.Connect;
           IdFTP.List(listaDirectory.Items, '', false);
           btnConnect.Enabled := False;
           btnDisconnect.Enabled := True;
           btnDownload.Enabled := True;
       end;
    except
         on E:Exception do
         begin
             MessageDlg('connection error!', mtError, [mbOK], 0);
             btnConnect.Enabled := true;
             btnDisconnect.Enabled := false;
             btnDownload.Enabled := false;
         end;
    end;
end;
procedure TCleint.btnDisconnectClick(Sender: TObject);
begin
    try
       if IdFTP.Connected then
       begin
           IdFTP.Disconnect;
           listaDirectory.Clear;
           btnConnect.Enabled := True;
           btnDisconnect.Enabled := False;
           btnDownload.Enabled := False;
       end;
    except
        on E:Exception do
        begin
          MessageDlg('connection error!', mtError, [mbOK], 0);
          btnConnect.Enabled := false;
          btnDisconnect.Enabled := true;
          btnDownload.Enabled := true;
        end;
    end;
end;
procedure TCleint.btnDownloadClick(Sender: TObject);
begin
end;
end.
				
                        
After calling
List(), you need to loop through the entries of theDirectoryListingproperty. That will tell you which items are files and which are subfolders. You can thenGet()the files and (recursively)ChangeDir()/List()the subfolders.