01-08-2022, 07:39 PM
Hello i working on lazarus ineed get a list f folders on ftpserver but allways show me empty list
here my code hope some body help me what i made wrong...
procedure TFomMain.FormShow(Sender: TObject);
var i,ld:integer;
Tr:tstrings;
fitring;
Tt:tidftplistitems;
T:tidftplistitem;
begin
FPXMLBFtp.LoadFromFile('FTPSetting.xml');
TR:= Tstringlist.create;
idFTP1.Host:= FPXMLBFTP.GetAttrValueByName('Server.ip', 'value');
idFTP1.Passive:=true;
idFTP1.Username:=FPXMLBFTP.GetAttrValueByName('Server.user', 'value');
idFTP1.Password:=FPXMLBFTP.GetAttrValueByName('Server.password', 'value');
idFTP1.Port:=strtoint(FPXMLBFTP.GetAttrValueByName('Server.port', 'value'));
Statusbar1.Panels[0].Text:='No Conncted , wait';
idFTP1.Connect;
if(idFTP1.Connected = true) then begin
Statusbar1.Panels[0].Text:='Conncted to '+ idFTP1.Host;
idFTP1.ChangeDir('..');
idFTP1.List('*',true);
Memo1.Lines.Add(idFTP1.RetrieveCurrentDir);
Memo1.Lines.Add( InttoSTr(idFTP1.ListResult.Count));
for i:=0 to Idftp1.directorylisting.Count-1 do begin
if((IdFTP1.DirectoryListing[I].ItemType = ditDirectory) and (IdFTP1.DirectoryListing[I].FileName <> '.') and (IdFTP1.DirectoryListing[I].FileName <> '..')) then begin
Memo1.Lines.Add(IdFTP1.DirectoryListing[I].FileName);
end else if( IdFTP1.DirectoryListing[I].ItemType = ditFile) then begin
Memo1.Lines.Add(IdFTP1.DirectoryListing[I].FileName);
end;
end;
// Listbox1.Items.Assign(Idftp1.directorylisting.Items);
Memo1.Lines.Add(idftp1.retrievecurrentdir);
// idFTP1.ChangeDir('Parts_Vendors');
// idFTP1.List(TR);
// Listbox1.Items.Assign(tr);
// Memo1.Lines.Assign (TR);
// if( FPXMLBFtp.GetAttrValueByName('Server.actiontoFtp', 'value') = 'Upload') then begin
// UploadFile(Sender);
// end else begin
// DownloadFile(Sender);
// end;
end;
here my code hope some body help me what i made wrong...
procedure TFomMain.FormShow(Sender: TObject);
var i,ld:integer;
Tr:tstrings;
fitring;
Tt:tidftplistitems;
T:tidftplistitem;
begin
FPXMLBFtp.LoadFromFile('FTPSetting.xml');
TR:= Tstringlist.create;
idFTP1.Host:= FPXMLBFTP.GetAttrValueByName('Server.ip', 'value');
idFTP1.Passive:=true;
idFTP1.Username:=FPXMLBFTP.GetAttrValueByName('Server.user', 'value');
idFTP1.Password:=FPXMLBFTP.GetAttrValueByName('Server.password', 'value');
idFTP1.Port:=strtoint(FPXMLBFTP.GetAttrValueByName('Server.port', 'value'));
Statusbar1.Panels[0].Text:='No Conncted , wait';
idFTP1.Connect;
if(idFTP1.Connected = true) then begin
Statusbar1.Panels[0].Text:='Conncted to '+ idFTP1.Host;
idFTP1.ChangeDir('..');
idFTP1.List('*',true);
Memo1.Lines.Add(idFTP1.RetrieveCurrentDir);
Memo1.Lines.Add( InttoSTr(idFTP1.ListResult.Count));
for i:=0 to Idftp1.directorylisting.Count-1 do begin
if((IdFTP1.DirectoryListing[I].ItemType = ditDirectory) and (IdFTP1.DirectoryListing[I].FileName <> '.') and (IdFTP1.DirectoryListing[I].FileName <> '..')) then begin
Memo1.Lines.Add(IdFTP1.DirectoryListing[I].FileName);
end else if( IdFTP1.DirectoryListing[I].ItemType = ditFile) then begin
Memo1.Lines.Add(IdFTP1.DirectoryListing[I].FileName);
end;
end;
// Listbox1.Items.Assign(Idftp1.directorylisting.Items);
Memo1.Lines.Add(idftp1.retrievecurrentdir);
// idFTP1.ChangeDir('Parts_Vendors');
// idFTP1.List(TR);
// Listbox1.Items.Assign(tr);
// Memo1.Lines.Assign (TR);
// if( FPXMLBFtp.GetAttrValueByName('Server.actiontoFtp', 'value') = 'Upload') then begin
// UploadFile(Sender);
// end else begin
// DownloadFile(Sender);
// end;
end;