L
lphy
Unregistered / Unconfirmed
GUEST, unregistred user!
代码:
procedure TForm1.DownAll(localpath:string; serverpath: String);
var
i,count1:integer;
ss:string;
att:TIdDirItemType;
FileList : TStrings;
begin
try begin
FileList := TStringList.Create;
memoupload.Lines.add('Changedir'+serverpath);
IdFTP1.ChangeDir(serverpath);
if AnsiLastChar(serverpath) <> '/' then
serverpath := serverpath + '/';
if AnsiLastChar(localpath) <> '/' then
localpath := localpath + '/';
if not DirectoryExists(localpath) then CreateDir(localpath);
IdFTP1.List(FileList);
count1:=IdFTP1.DirectoryListing.Count;
for i:=0 to count1-1 do begin
ss:=IdFTP1.DirectoryListing.Items[i].FileName;
att:=IdFTP1.DirectoryListing.Items[i].ItemType;
if (att<>ditDirectory) and (ss <> '.') AND (ss <> '..') then begin
if not DirectoryExists(localpath) then CreateDir(localpath);
IdFTP1.Get(serverpath+ss,localpath+ss,true);
end
end;
for i:=0 to count1-1 do begin
ss:=IdFTP1.DirectoryListing.Items[i].FileName;
att:=IdFTP1.DirectoryListing.Items[i].ItemType;
if (att=ditDirectory) and (ss <> '.') AND (ss <> '..') then begin
DownAll(localpath+ss,serverpath+ss);
end;
end;
IdFTP1.ChangeDirUp;
Filelist.Free;
end
except
end;
end;