Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Jul : Indy 10 TIdFTP

www.cryer.info
Managed Newsgroup Archive

Indy 10 TIdFTP

Subject:Indy 10 TIdFTP
Posted by:"Jack Mason" (jackmas..@mindspring.com)
Date:Fri, 21 Jul 2006 00:05:41

Thanks to Remy, I am back trying Indy 10 again.  Almost got it to work
like it used to, but of course I changed a few things, and wanted to
make a few improvements, so one part still doesn't work.  Looking at the
  Indy 10 documentation in BDS 2006, the property "DirectoryListing"
should do what I needed to do.

I replaced List(Dir_List, '*', true); with simply List;  Checking the
property "ListResult.CommaText" does in fact return the entire comma
delimited list of files.  However, neither "DirectoryListing.Count" nor
does "DirectoryListing.Items[0].FileName" exist.

Given my past history with FTP, there is most likely something I am missing.

Here is the entire code:

unit Export;

interface

uses
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms,
   Dialogs, IdAntiFreezeBase, IdAntiFreeze, IdBaseComponent, IdComponent,
   IdTCPConnection, IdTCPClient, IdFTP, StdCtrls,
IdExplicitTLSClientServerBase;

type
   TForm1 = class(TForm)
     Server_Name: TEdit;
     Label1: TLabel;
     User_Name: TEdit;
     Pass_Word: TEdit;
     Label2: TLabel;
     Label3: TLabel;
     Label4: TLabel;
     Memo_Log: TMemo;
     Button1: TButton;

     IdAntiFreeze1: TIdAntiFreeze;
     IdFTP1: TIdFTP;
     procedure Button1Click(Sender: TObject);

   private
     { Private declarations }
   public
     { Public declarations }
   end;

var
   Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var Idx: integer;
begin
   Memo_Log.Lines.Clear;
   with IdFTP1 do
    try
     Username := User_Name.Text;
     Password := Pass_Word.Text;
     Host := Server_Name.Text;
     Connect;
     Current_Directory := IdFTP1.RetrieveCurrentDir;
     ChangeDir(Current_Directory + 'test');
     Memo_Log.Lines.Add('New Directory: ' + IdFTP1.RetrieveCurrentDir);
     List;
     Memo_Log.Lines.Add(ListResult.CommaText);
     Memo_Log.Lines.Add('Items in directory: ' +
IntToStr(DirectoryListing.Count));
     Memo_Log.Lines.Add('Got Directory List');
     for Idx := 0 to DirectoryListing.Count - 1 do
        Memo_Log.Lines.Add('  ' + DirectoryListing.Items[Idx].FileName);
     Memo_Log.Lines.Add('Listed Directory & Done ');
   finally
     IdFTP1.Disconnect;
   end;
end;

end.

Replies:

www.cryer.info
Managed Newsgroup Archive