ftp服务器出现假文件夹,ICS FTP - 检查功能如果FTP服务器上存在的文件夹

我试图创建一个函数来检查是否存在一个文件夹使用Overbyte ICS FTP component.Using从icsftp DIR命令不会在我的笔记显示什么登录。 我有兴趣将dir命令的结果解析为字符串列表以搜索特定的文件夹。ICS FTP - 检查功能如果FTP服务器上存在的文件夹

目前我使用这样的indy函数。我怎样才能与ICS做同样的事情?

function exista_textul_in_stringlist(const stringul_pe_care_il_caut:string; stringlistul_in_care_efectuez_cautarea:Tstringlist):boolean;

begin

if stringlistul_in_care_efectuez_cautarea.IndexOf(stringul_pe_care_il_caut) = -1 then

begin

result:=false;

//showmessage('Textul "'+text+'" nu exista!');

end

else

begin

result:=true;

//showmessage('Textul "'+text+'" exista la pozitia '+ inttostr(ListBox.Items.IndexOf(text)));

end;

end;

function folder_exists_in_ftp(folder_name_to_search_for,ftp_hostname,ftp_port,ftp_username,ftp_password,ftp_root_folder:string;memo_loguri:Tmemo):boolean;

Var

DirList : TStringList;

ftp:Tidftp;

antifreeze:TidAntifreeze;

var i,k:integer;

begin

dateseparator:='-';

Result := False;

DirList := TStringList.Create;

ftp:=tidftp.Create;

antifreeze:=TidAntifreeze.Create;

try

antifreeze.Active:=true;

ftp.Host:=ftp_hostname;

ftp.Port:=strtoint(ftp_port);

ftp.username:=ftp_username;

ftp.password:=ftp_password;

ftp.Passive:=true;

ftp.Connect;

ftp.ChangeDir(ftp_root_folder);

ftp.List(DirList, folder_name_to_search_for, True);

if DirList.Count > 0 then begin

k := DirList.Count;

DirList.Clear; // DIRLIST will hold folders only

for i := 0 to k - 1 do begin

if (ftp.DirectoryListing.Items[i].FileName <> '.') and (ftp.DirectoryListing.Items[i].FileName <> '..') then begin

if ftp.DirectoryListing.Items[i].ItemType = ditDirectory then begin

DirList.Add(ftp.DirectoryListing.Items[i].FileName);

end;

end;

end;

end;

if exista_textul_in_stringlist(folder_name_to_search_for,DIRLIST) then

begin

Result := True;

memo_loguri.Lines.Add(datetimetostr(now)+' - caut folderul "'+folder_name_to_search_for+'" in directorul ftp "'+ftp_root_folder+'" => EXISTS!');

end

ELSE

begin

result:=false;

memo_loguri.Lines.Add(datetimetostr(now)+' - caut folderul "'+folder_name_to_search_for+'" in directorul ftp "'+ftp_root_folder+'" => NOT exists!');

end;

finally

ftp.Free;

antifreeze.Free;

DirList.Free;

end;

end;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值