Downloading directory from FTP server
2016-02-26 16:32
627 查看
You need to call
For example:
Usage:
TIdFTP.ChangeDir()to go to the desired starting directory, then call
TIdFTP.List()to retrieve the names of its files and subdirectories, then loop through the
TIdFTP.DirectoryListingcalling
TIdFTP.Get()on each filename and store each subdirectory name into your own local list, then finally repeat the above steps on each subdirectory in your local list.
For example:
Procedure DownloadFolder(ARemoteFolder, ALocalFolder: string); Var SubFolders: TStringList; I: Integer; Begin ALocalFolder := IncludeTrailingPathDelimiter(ALocalFolder); ForceDirectories(ALocalFolder); SubFolders := TStringList.Create; Try FTP.ChangeDir(ARemoteFolder); FTP.List; For I := 0 to FTP.DirectoryListing.Count-1 do Begin If FTP.DirectoryListing[I].ItemType = ditFile then Begin FTP.Get(FTP.DirectoryListing[I].FileName, ALocalFolder + FTP.DirectoryListing[I].FileName); End Else if FTP.DirectoryListing[I].ItemType = ditDirectory then Begin SubFolders.Add(FTP.DirectoryListing[I].FileName); End; End; For I := 0 to SubFolders.Count-1 do Begin DownloadFolder(ARemoteFolder + '/' + SubFolders[I], ALocalFolder + SubFolders[I]); End; Finally SubFolders.Free; End; End;
Usage:
DownloadFolder('/StartingDir', 'C:\Downloaded');
相关文章推荐
- zabbix报PHP gettext extension missing
- yii kartik\grid\GridView 插件应用
- 详解PHP的Laravel框架中Eloquent对象关系映射使用
- CGI与fastcgi与php-fpm与php-cgi的关系
- PHP定义命令空间的几个注意点
- Yii 2.0: How to implement cron in Yii 2
- PHP time zone unknown Fail
- zabbix监控php-fpm性能状态
- 如何自动化一键部署PHP项目
- TPROXY - Transparent proxy - UDP program - RHEL6
- Yii2简单地址美化并隐藏index.php
- PHP解码base64编码的图片例
- 使用php创建WebSocket服务
- phpcms v9的url优化
- 解决安装ECshop时PHP版本大于5.2时的问题
- php websocket聊天室
- 安装phpMyAdmin图文教程
- 用PHP写和调用webservice最简单方法
- PHP正则表达式提取html超链接中的href地址
- 牛人写的facebook优化php来龙去脉