INDY FTP Client客户端组件使用问题,急!!!(解决了,顶贴散分了)(100分)

  • 主题发起人 主题发起人 goodpb2006
  • 开始时间 开始时间
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;
 
倒,研究了一晚上,刚在INDY官网上查到解决方法,居然是没有包含IdFTPListParseUnix单元,包含后就OK了

附上原文,供大家参考:(好象只适用于INDY10)
TIdFTP.DirectoryListing is returning nothing for my FTP server. Why?

We restructured the way FTP directory listing is done. The code is now a plug in system with various parsers in their own units which register themselves into a framework. To add support for a particular type of FTP server, you simply add the parser unit to one of your program unit's uses clause.



To add the Unix directory list parser, add IdFTPListParseUnix to your unit's clause. To add support for Microsoft Windows NT IIS FTP server, add IdFTPListParseWindowsNT to your uses clause. You can also add many other parsers we include in the Indy packages. By convention, they are named IdFTPListParser followed by the server type. You do not need to add IdFTPListParseBase to your uses clause because IdFTP uses that unit. If you wish to use all of Indy's FTP List parser classes, just add the IdAllFTPListParsers unit to your uses clause.



We admit this new design is not as intuitive as the older one but this has many advantages for us such as:



&#8226; The FTP list parsing code is now much easier to maintain than the same code in a non-modular design in one unit which would be at least 150KB total.

&#8226; You now can add support for only the FTP servers you want your program support to support.

&#8226; You can now write your own custom parser classes and plug those into the standard FTP parsing list framework.

大家顶贴,明早散分了,先睡了
 
本想多等点人顶好散分,结果就你一个人顶哟,那就给你100分,[:D]
 
后退
顶部