使用ftp控件下载一个目录(附一则笑话) (转)

使用ftp控件下载一个目录(附一则笑话) (转)[@more@]

 

 

Delphi中的nmFTP控件DOWNLOAD函数只能下载一个文件,没有提供一个下载整个目录(包含子目录)的函数。
我编写了个实现目录下载功能的方法,需要用到该功能的用户可参考一下。
file://目录下载
function tftp.ex_download(remote_dir,local_dir:string):boolean;
var
  i,j,count1:integer;
  att,ss:string;
  current_dir:string;
  temp_dir:string;
begin
  try begin
  NMFTP1.ChangeDir(remote_dir);
  current_dir:=remote_dir;
  temp_dir:=copy(current_dir,2,length(current_dir));
  if not DirectoryExists(local_dir) then CreateDir(local_dir);
  if not directoryexists(local_dir+temp_dir) then createdir(local_dir+temp_dir);
  nmftp1.ParseList:=true;
  NMftp1.list;
  count1:=nmftp1.FTPDirectoryList.name.Count;
  for i:=0 to count1-1  do begin
  file://必
  NMFTP1.ChangeDir(current_dir);
  nmftp1.list;
  ss:=nmftp1.FTPDirectoryList.name.Strings[i];
  att:=nmftp1.FTPDirectoryList.Attribute.Strings[i];
  if (copy(pchar(att),1,1)<>'d')and(copy(pchar(att),1,1)<>'D') then begin
  if not DirectoryExists(local_dir) then CreateDir(local_dir);
  NMFTP1.Download(current_dir+ss,local_dir+temp_dir+ss);
  end
  else begin
  if not directoryexists(local_dir+temp_dir+ss) then createdir(local_dir+temp_dir+ss);
  file://递调用
  ex_download(remote_dir+ss+'',local_dir);
  end;
  end;
  result:=true;
  end
  except
  On E:Exception do begin
  result:=false;
  end;
  end;
end;

————————————————————————————————————————————————————————————
老大晕倒了

一天,上班时间,我在电脑前“工作”,这时,老大过来了。
老大:小刘啊,上班时间不要看flash动画。
小刘:我很少看。
老大:很少看?你看你机器目录名为”阿贵“的目录,肯定都有三`四十兆了。
小刘:老大,冤枉啊,哪有那么多……
老大:没有30兆,至少也该有20兆吧。
小刘:老大你过来看……文件夹……”阿贵“……属性……,只有……142兆!!!……啊,老大,你怎么了,快醒醒啊……
————————————————————————————————————————————————————————————

更多的原创技巧文档和关于程序员的幽默,请访问我个人主页http://aton.126.com


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10752043/viewspace-988566/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10752043/viewspace-988566/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值