G
goodpb2006
Unregistered / Unconfirmed
GUEST, unregistred user!
使用idFTP Client做目录遍历下载时,为什么DirectoryListing.Count一直都是为0呀
使用的Indy10,Borland delphi 2006自带的
附上部分源码:
procedure TBase_Download.Func_FTPDownloadDir(RemoteDir,LocalDir : string);
var
i,DirCount : integer;
TmpFiles:TStringList;
begin
TmpFiles:=TStringList.Create;
with FFTPClient do
begin
if not DirectoryExists(LocalDir + RemoteDir) then
ForceDirectories(LocalDir + RemoteDir);
if RemoteDir<>'/' then
ChangeDir(RemoteDir)
else
ChangeDir('/');
TransferType:=ftASCII;
List(TmpFiles,'*.*',True);
/*******下面这一句一直取的值都是0,为什么呀!*********/
/*******上面已经进行了LIST,为什么还是不行呢!********/
/*******TmpFiles的count却可以取到实际数目,为什么呀!*********/
DirCount := DirectoryListing.Count ;
if DirCount = 0 then
begin
ChangeDirUp;
List;
end;
for i := 0 to DirCount - 1 do
begin
if DirCount <> DirectoryListing.Count then
begin
repeat
ChangeDirUp;
List;
until DirCount = TmpFiles.Count ;
end;
if DirectoryListing.Items.ItemType = ditDirectory then
Func_FTPDownloadDir(DirectoryListing.FileName,LocalDir + RemoteDir + '/')
else
begin
Get(DirectoryListing.FileName,LocalDir + RemoteDir + '/' +
DirectoryListing.FileName,true,true);
if i = DirCount - 1 then
begin
ChangeDirUp;
List;
end;
end;
end;
end;
TmpFiles.Free;
end;
使用的Indy10,Borland delphi 2006自带的
附上部分源码:
procedure TBase_Download.Func_FTPDownloadDir(RemoteDir,LocalDir : string);
var
i,DirCount : integer;
TmpFiles:TStringList;
begin
TmpFiles:=TStringList.Create;
with FFTPClient do
begin
if not DirectoryExists(LocalDir + RemoteDir) then
ForceDirectories(LocalDir + RemoteDir);
if RemoteDir<>'/' then
ChangeDir(RemoteDir)
else
ChangeDir('/');
TransferType:=ftASCII;
List(TmpFiles,'*.*',True);
/*******下面这一句一直取的值都是0,为什么呀!*********/
/*******上面已经进行了LIST,为什么还是不行呢!********/
/*******TmpFiles的count却可以取到实际数目,为什么呀!*********/
DirCount := DirectoryListing.Count ;
if DirCount = 0 then
begin
ChangeDirUp;
List;
end;
for i := 0 to DirCount - 1 do
begin
if DirCount <> DirectoryListing.Count then
begin
repeat
ChangeDirUp;
List;
until DirCount = TmpFiles.Count ;
end;
if DirectoryListing.Items.ItemType = ditDirectory then
Func_FTPDownloadDir(DirectoryListing.FileName,LocalDir + RemoteDir + '/')
else
begin
Get(DirectoryListing.FileName,LocalDir + RemoteDir + '/' +
DirectoryListing.FileName,true,true);
if i = DirCount - 1 then
begin
ChangeDirUp;
List;
end;
end;
end;
end;
TmpFiles.Free;
end;