g[i].filename,true);
form1.lb_num.caption := inttostr(strtoint(form1.lb_num.caption) + 1);
form1.lb_num.update;
if i = dircount - 1 then
begin
idftp.changedirup;
idftp.list(nil);
end;
end;
end;
end;
{删除整个ftp目录,包括下面的文件,
rootdir = 要删除的根目录,一般情况下 remotedir 与 rootdir 相等}
procedure ftp_deleteallfiles(var idftp : tidftp;remotedir,rootdir : string);
label files;
var
i,dircount : integer;
temp : string;
begin
idftp.changedir(remotedir);
if pos(rootdir,idftp.retrievecurrentdir) = 0 then exit;
files :
idftp.list(nil);
dircount := idftp.directorylisting.count ;
while dircount = 0 do
begin
temp := idftp.retrievecurrentdir;
idftp.changedirup;
idftp.removedir(temp);
idftp.list(nil);
dircount := idftp.directorylisting.count ;
for i := 0 to dircount - 1 do
if idftp.directorylisting[i].filename = rootdir then exit;
end;
for i := 0 to dircount - 1 do
begin
if pos(rootdir,idftp.retrievecurrentdir) = 0 then break ;
if idftp.directorylisting[i].itemtype = ditdirectory then
begin
ftp_deleteallfiles(idftp,idftp.directorylisting[i].filename,rootdir);
end else begin
idftp.delete(idftp.directorylisting[i].filename);
form1.lb_num.caption := inttostr(strtoint(form1.lb_num.caption) + 1);
form1.lb_num.update;
goto files ;
end;
end;
end;
procedure tform1.btt_downloaddirclick(sender: tobject);
begin
idftp1.connect(true,-1);
if idftp1.connected then
begin
idftp1.changedir(''bigimage'');
ftp_downloaddir(idftp1,''1002.1002.1002'',''g:\ftpdir\'');
end;
idftp1.disconnect ;
end;
procedure tform1.btt_deletedirclick(sender: tobject);
begin
idftp1.connect(true,-1);
if idftp1.connected then
begin
idftp1.changedir(''bigimage'');
ftp_deleteallfiles(idftp1,''1002.1002.1002'',''1002.1002.1002'');
end;
idftp1.disconnect ;
end;
end.