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;
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...
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...
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...
Best regards,
Kristian Andersen
"Kristian Andersen" <hastrup...@hotmail.com> wrote in message
news:3b8177c1_1@dnews...
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"