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

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

 

 

{ 下载整个目录,并遍历所有子目录

  首先 ChangeDir(Root) 到根目录

  然后创建本地目录 + RemoteDir

  然后用 list 得到所有目录名

  循环判断,进入 RemoteDir 目录内部

  如果是目录继续第归。否则 get 该文件到本地目录,当 get 完所有文件后返回上一级目录

  用List再取得信息,继续循环

 }

 

procedure FTP_DownloadDir(var idFTP : TIdFtp;RemoteDir,LocalDir : string);

label Files ;

var

  i,DirCount : integer;

begin

  if not DirectoryExists(LocalDir + RemoteDir) then

    ForceDirectories(LocalDir + RemoteDir);

  idFTP.ChangeDir(RemoteDir);

  idFTP.List(nil);

  DirCount := idFTP.DirectoryListing.Count ;

  if DirCount = 0 then

  begin

    idFTP.ChangeDirUp;

    idFTP.List(nil);

  end;

  for i := 0 to DirCount - 1 do

  begin

    if DirCount <> idFTP.DirectoryListing.Count then

    begin

      repeat

        idFTP.ChangeDirUp;

        idFTP.List(nil);

      until DirCount = idFTP.DirectoryListing.Count ;

    end;

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

      FTP_DownloadDir(idFTP,idFTP.DirectoryListing[i].FileName,LocalDir + RemoteDir + '')

    else begin

      idFTP.Get(idFTP.DirectoryListing[i].FileName,LocalDir + RemoteDir + '' +

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

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

阅读排行

相关文章

没有相关文章

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

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

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