Var
Strnowdir, FileName: string;//FileName, the name,
Dir_List: TStringList;
I: Integer;
The begin
I:=0;
Try
Strnowdir:=FTPLJ;
If idftp1. RetrieveCurrentDir<> '\' then
The begin
IdFTP1. ChangeDirUp;
IdFTP1. ChangeDirUp;
IdFTP1. ChangeDirUp;
end;
IdFTP1. ChangeDir (strnowdir);
Dir_List:=TStringList. Create;
Idftp1. List (Dir_List);
IDFTP1. TransferType:=ftBinary;
If Dir_List. Count=0 then the Exit;
//judge whether directory
If (IdFTP1. The DirectoryListing. Items [I] ItemType=ditDirectory) then
The begin
IdFTP1. ChangeDir (strnowdir);
end;
For I:=0 to Dir_List. Do the Count - 1
The begin
FileName:=IdFTP1. The DirectoryListing. Items [I] FileName.
Showmessage (FileName);
If (IdFTP1. The DirectoryListing. Items [I] ItemType=ditFile) then
//if any local files, whether download after covering the local file//and (IdFTP1. The DirectoryListing. Items [I] ModifiedDate & gt; StrToDate (' 2011-3-19 '))
The begin
If FileExists (BDLJ + IdFTP1. The DirectoryListing. Items [I] FileName) then
The begin
//ShowMessage (' file have downloaded ');
The Continue;
End
The else
The begin
IdFTP1. Get (IdFTP1. The DirectoryListing. Items [I] FileName, BDLJ + IdFTP1. The DirectoryListing. Items [I] FileName, False, true);
end;
The end;
end;
//showmessage (FTPLJ + 'download success);
Dir_List. Free;
Except,
;
end;
end;
Each time to IdFTP1. The DirectoryListing. Items [I] ItemType=ditDirectory will quote us this exception
CodePudding user response:
Here:IdFTP1. ChangeDir (strnowdir);
Still need to call the List method, to try the following
If (IdFTP1. The DirectoryListing. Items [I] ItemType=ditDirectory) then
The begin
IdFTP1. ChangeDir (strnowdir);
Idftp1. List (Dir_List);
end;