Click here to Skip to main content
15,891,777 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted

1 solution

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
 
Share this answer
 
v2
Comments
Espen Harlinn 15-Oct-11 9:16am    
Good answer :)
Sergey Alexandrovich Kryukov 15-Oct-11 19:45pm    
Thank you, Espen.
--SA
Simon Bang Terkildsen 15-Oct-11 18:18pm    
My 5
Sergey Alexandrovich Kryukov 15-Oct-11 19:45pm    
Thank you, Simon.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900