0

有人知道如何使用 Over byte ICS FTP 检查文件是否存在于 ftp 服务器上?我必须列出所有文件然后解析结果还是有另一种方法可以做到这一点?谢谢你。

我习惯在 Indy 中编写以下代码。它可以工作。但在我的项目中,我想使用 icsftp。如何为 ics ftp 更改此设置?

Function exista_fisier_pe_ftp_nonvizual(nume_fisier_cautat,ftp_host,ftp_port,ftp_username,ftp_password,ftp_directory:string;memo_loguri:Tmemo) :Boolean;
var l:TStringList;
    indyftp:Tidftp;
    Freq, StartCount, StopCount: Int64;
    TimingSeconds: real;

begin

dateseparator:='-';


{verific daca serverul ftp este ONLINE}
if not IS_FTP_ONLINE(ftp_username,ftp_password,ftp_host) then showmessage(datetimetostr(now)+' - serverul "'+ftp_host+'" este OFFLINE sau datele de conectare sunt incorecte!') else

begin

memo_loguri.Lines.Add(#13#10+'=====> START CAUTARE FISIER PE SERVER FTP <====='+#13#10);

{ START VERIFICARE VITEZA DE EXECUTIE }
QueryPerformanceFrequency(Freq);
QueryPerformanceCounter(StartCount);



indyftp:=Tidftp.create(nil);
l:=tstringlist.create;

indyftp.Host:=ftp_host;
indyftp.Port:=strtoint(ftp_port);
indyftp.username:=ftp_username;
indyftp.password:=ftp_password;
indyftp.Passive:=true;
indyftp.Connect;

if indyftp.connected then
 begin
memo_loguri.Lines.Add(datetimetostr(now)+' - conectat cu succes la "'+indyftp.Host+'" portul '+inttostr(indyftp.Port));
memo_loguri.Lines.add(datetimetostr(now)+' - detectare sistem de operare server ftp: "'+indyftp.SystemDesc+'"');

indyftp.ChangeDir(ftp_directory);

memo_loguri.Lines.add(datetimetostr(now)+' - accesez directorul "'+ftp_directory+'"');

 try
{listez toate fisierele de pe ftp}
indyftp.List(l, '', false);

if l.IndexOf(nume_fisier_cautat) > -1 then
begin
result:=true;
memo_loguri.Lines.add(datetimetostr(now)+' - fisierul "'+nume_fisier_cautat+'" exista pe serverul ftp in directorul "'+indyftp.RetrieveCurrentDir+'" ,are dimensiunea de '+ FormatByteSize(indyFTP.Size(nume_fisier_cautat))+' si a fost incarcat pe server la data ' +datetostr(indyFTP.FileDate(nume_fisier_cautat)));
end
else
begin
result:=false;
memo_loguri.Lines.add(datetimetostr(now)+' - fisierul "'+nume_fisier_cautat+'" nu exista pe serverul ftp');
end;

finally
  l.free;
end;
  indyftp.free;


{ STOP VERIFICARE VITEZA DE EXECUTIE }
QueryPerformanceCounter(StopCount);
TimingSeconds := (StopCount - StartCount) / Freq;
{ Display timing: ... }
memo_loguri.Lines.Add(datetimetostr(now) + ' - comanda executata in: ' + formatfloat('0.00',TimingSeconds) + ' sec.'+#13#10);
memo_loguri.Lines.Add('=====> STOP CAUTARE FISIER PE SERVER FTP <====='+#13#10);

end;
end;
end;
4

0 回答 0