您现在的位置: 中国教师站 >> 教师关注 >> 电脑技术 >> 编程技术 >> Delphi >> 正文

Google
如何用idFTP遍历整个目录----下载、删除
作者:Siny 文章来源:中国教师站cn-teacher 点击数: 更新时间:2007-4-22 15:47:32
        idFTP.DirectoryListing[i].FileName,true);

      Form1.lb_num.Caption := IntToStr(StrToInt(Form1.lb_num.Caption) + 1);

      Form1.lb_num.Update;

      if i = DirCount - 1 then

      begin

        idFTP.ChangeDirUp;

        idFTP.List(nil);

      end;

    end;

  end;

end;

 

{删除整个ftp目录,包括下面的文件,

 RootDir = 要删除的根目录,一般情况下 RemoteDir 与 RootDir 相等}

procedure FTP_DeleteAllFiles(var idFTP : TIdFtp;RemoteDir,RootDir : string);

label Files;

var

  i,DirCount : integer;

  Temp : string;

begin

  idFTP.ChangeDir(RemoteDir);

  if Pos(RootDir,idFTP.RetrieveCurrentDir) = 0 then Exit;

Files :

  idFTP.List(nil);

  DirCount := idFTP.DirectoryListing.Count ;

  while DirCount = 0 do

  begin

    Temp := idFTP.RetrieveCurrentDir;

    idFTP.ChangeDirUp;

    idFTP.RemoveDir(Temp);

    idFTP.List(nil);

    DirCount := idFTP.DirectoryListing.Count ;

    for i := 0 to DirCount - 1 do

    if idFTP.DirectoryListing[i].FileName = RootDir then Exit;

  end;

  for i := 0 to DirCount - 1 do

  begin

    if Pos(RootDir,idFTP.RetrieveCurrentDir) = 0 then Break ;

    if idFTP.DirectoryListing[i].ItemType = ditDirectory then

上一页  [1] [2] [3] [4] 下一页

相关专题:
 
 网友评论:(评论内容只代表网友观点,与本站立场无关!)
GOOGLE广告

阅读排行

相关文章

没有相关文章

| 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 版权申明 |
中国教师站

中国教师站 版权所有 Copyright © 2006-2020 All Rights Reserved 站长:Sina & Siny
[备用域名:www.JXZYW.Com] 有事请留言有事请留言
【实力成就精品 诚信呵护品牌】

信息产业部备案
苏ICP备06018635号