Hello.
What is the best way to download all files in a remote directory using C# and FTP and save them to a local directory?
thanks
Hello.
What is the best way to download all files in a remote directory using C# and FTP and save them to a local directory?
thanks
Look at
http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest_members.aspx
another implementation. http://www.codeproject.com/KB/IP/ftplib.aspx
Hi,
downloading all files in a specific folder seems to be an easy task. However, there are some issues which has to be solved. To name a few:
Decent third party FTP component should have a method for handling those issues. Following code uses our Rebex FTP for .NET.
using (Ftp client = new Ftp())
{
// connect and login to the FTP site
client.Connect("mirror.aarnet.edu.au");
client.Login("anonymous", "my@password");
// download all files
client.GetFiles(
"/pub/fedora/linux/development/i386/os/EFI/*",
"c:\\temp\\download",
FtpBatchTransferOptions.Recursive,
FtpActionOnExistingFiles.OverwriteAll
);
client.Disconnect();
}
The code is taken from my blogpost available at blog.rebex.net. The blogpost also references a sample which shows how ask the user how to handle each problem (e.g. Overwrite/Overwrite older/Skip/Skip all).
You can use FTPClient from laedit.net. It's under Apache license and easy to use.
You could use System.Net.WebClient.DownloadFile()
, which supports FTP. MSDN Details here