Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TFTPDirectoryList object (of Delphi's FTP component)

128 views
Skip to first unread message

V. Shypoorchian

unread,
Aug 19, 2001, 6:24:39 AM8/19/01
to
Hi,

I am using the standard Delphi FTP client component, and have a problem with
the TFTPDirectoryList object.
In the online help I read that settings the components ParseList prop. to
True would fill the FTPDirectoryList object with directory listings (after a
call to List). When I check the content of this object in the OnSucces Event
the Count property of the Name property is 0. How is this possible?

This is the code I use, and the Parselist prop is set to true.

procedure TfmNewSet_Start1.ftpConnect(Sender: TObject);
begin
ShowMessage('connected');
NMFTP.List;
end;

procedure TfmNewSet_Start1.ftpSuccess(Trans_Type: TCmdType);
var
i:integer;
begin
case Trans_Type of
cmdList:
for I:=0 to NMFTP.FTPDirectoryList.Name.Count-1 do
Memo1.Lines.Add(NMFTP.FTPDirectoryList.name[I]);
end;
end;

Kristian Andersen

unread,
Aug 19, 2001, 3:13:32 PM8/19/01
to
Hi,

Are you sure there are any files on the FTP server you connect to ?

You could try to use the OnListItem event which will be called once for each
file found in the directory.

It works for me, however I place the "FTPDirectoryList" code right after the
"List" call ....

Best regards,
Kristian Andersen

"V. Shypoorchian" <wa...@quicknet.nl> wrote in message
news:3b7f93f9_1@dnews...

V. Shypoorchian

unread,
Aug 20, 2001, 2:24:43 AM8/20/01
to
Yes, I am sure. Cause when I use the OnListItem it works fine.

Maybe you could show me your code?

--
Met vriendelijke groeten,

Vahid Shypoorchian
"Kristian Andersen" <hastrup...@hotmail.com> schreef in bericht
news:3b800dff$1_1@dnews...

Kristian Andersen

unread,
Aug 20, 2001, 4:56:51 PM8/20/01
to
Sure. This is how it works (I have removed some database handling which is
not needed):

I connect to the FTP server. When the connection is made, the FTPConnect
event is triggered - this is where I put my code.

procedure TFMain.FTPConnect(Sender: TObject);
var
i : integer;
ok : boolean;
begin
ok := true;
FTP.Mode(MODE_ASCII); // use ascii, else cr/lf is wrong
FTP.Vendor := NMOS_AUTO;

// get list of files
try
FTP.ParseList := true;
FTP.List();
except
ok := false;
end;
if ok = true then
begin
// parse list
for i := 0 to FTP.FTPDirectoryList.name.Count - 1 do
begin
if FTP.FTPDirectoryList.Attribute[i][1] = '-' then // file - not a
directory !
begin
try
FTP.Download(FTP.FTPDirectoryList.name[i], local_dir +
'onefile.txt');
except
ok := false;
end;
if ok = true then
ok := process_onefile();
// do something if ok = false ...
end;
end;
end;
FTP.Disconnect();
end;

BUT BUT BUT - I do have one problem which I posted in this group a few days
ago: Most of the time this code works but sometimes the LIST call does not
return and the program stops responding. So I wonder: Is this the correct
way to do it ?

Kristian Andersen

"V. Shypoorchian" <wa...@quicknet.nl> wrote in message

news:3b80ad70_1@dnews...

Kristian Andersen

unread,
Aug 21, 2001, 10:42:45 AM8/21/01
to
It seems there is a bug in the list() command - I have not found a solution
yet.

Best regards,
Kristian Andersen

"Kristian Andersen" <hastrup...@hotmail.com> wrote in message
news:3b8177c1_1@dnews...

Kudzu - Team Indy

unread,
Aug 25, 2001, 4:15:32 AM8/25/01
to
"Kristian Andersen" <hastrup...@hotmail.com> wrote in news:3b84163b$1_2
@dnews:

> It seems there is a bug in the list() command - I have not found a solution
> yet.

The fix to all the NM bugs is to dump them. Use Indy or ICS instead. They are
both free, come with source, and most importantly, they work.


--
Chad Z. Hower (Kudzu) - http://www.pbe.com/Kudzu/
Current Location: St. Petersburg, Russia
"Programming is an art form that fights back"


0 new messages