[code]
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;
[/code]
我根据网上的nmftp递归下载的程序改编的,但是只能下载一部分目录及文件,请各位大侠帮指明其中的错误  
错误情况:
服务器目录
/abc/
/abc/01/
/abc/01/001/
/abc/01/001/123.htm
/abc/01/001/456.htm
/abc/01/001/789.htm
/abc/01/002/
/abc/01/002/111.htm
/abc/01/002/222.htm
/abc/01/002/333.htm
/abc/02/112.htm
/abc/02/113.htm只能下载
/abc/
/abc/01/
/abc/01/001/
/abc/01/001/123.htm
/abc/01/001/456.htm
/abc/01/001/789.htm
其它目录就下不了

解决方案 »

  1.   

    没看出有什么毛病啊,可能是IdFTP1.ChangeDirUp;没有返回到上级目录,你可以调试一下看看
    如果像你所说的,问题应该是比较明显,就是程序在下载完第一个明细目录无法返回上一个目录,你关键看看这一部分吧
      

  2.   

    IdFTP1.ChangeDirUp
    没问题能返回上级目录的
    这个问题我已经搞了几天了,怎么搞也没搞出来,请那位高人指点一下
    或者有类是的代码贴出来学习一下:)