从ftp服务器下载一个完整的文件夹及其文件 [英] download a complete folder with its files from ftp server

查看:201
本文介绍了从ftp服务器下载一个完整的文件夹及其文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想从ftp服务器下载一个完整的文件夹及其文件.

如果您为此编写代码和库,请与我分享...



例如,有一个文件夹"hello",其中包含3个文件和1个目录子文件夹",其中包含一个文件.

Hi,
I want to download a complete folder with its files from ftp server.

Plz share me if you code and libraries for that...



For Example, there is a folder "hello" with 3 files and 1 directory "subfolder" which has one file in it.

推荐答案

这是一个非常简单的任务,通过使用类System.Net.FtpWebRequestSystem.Net.WebResponse解决.从目录下载文件的操作将是一个复合操作,先后顺序获取目录列表和大量文件下载操作(可选地以递归方式).这些操作由静态类 System.Net.WebRequestMethods.Ftp表示.您需要的操作是System.Net.WebRequestMethods.Ftp.DownloadFileSystem.Net.WebRequestMethods.Ftp.ListDirectorySystem.Net.WebRequestMethods.Ftp.ListDirectoryDetails.

请参见带有一些代码示例的MSDN帮助页面:
http://msdn.microsoft.com/en-us/library/system.net. ftpwebrequest.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/system.net. ftpwebresponse.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/system. net.webrequestmethods.ftp.aspx [ ^ ].

拥有所有这些信息和代码示例之后,您可以考虑所需的源代码已基本完成.

—SA
This is a pretty simple task, solved by using the classes System.Net.FtpWebRequest and System.Net.WebResponse. Your operation of downloading files from a directory would be a compound operation sequencing getting directory lists followed by a number of file downloading operations, optionally in a recursive manner. Those operations are represented by the static class System.Net.WebRequestMethods.Ftp. The operations you need are System.Net.WebRequestMethods.Ftp.DownloadFile and System.Net.WebRequestMethods.Ftp.ListDirectory or System.Net.WebRequestMethods.Ftp.ListDirectoryDetails.

See MSDN help pages with some code samples:
http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.aspx[^],
http://msdn.microsoft.com/en-us/library/system.net.ftpwebresponse.aspx[^],
http://msdn.microsoft.com/en-us/library/system.net.webrequestmethods.ftp.aspx[^].

Having all this information and code samples, you can consider the source code you need is almost done.

—SA


这篇关于从ftp服务器下载一个完整的文件夹及其文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆