I can transfer one file from ftp server to local directory. using the following code
using (WebClient ftpClient = new WebClient())
{
ftpClient.Credentials = new System.Net.NetworkCredential("username", "password");
ftpClient.DownloadFile("ftp://website.com/abcd.docx", @"D:\\WestHam\test.docx");
but i don't know how to transfer multiple files. can anybody help me on this. }
Use this code, just replace the user credentials:
Very Great and simple library FluentFTP
Check it out;
My config file:
<?xml version="1.0" encoding="utf-8" ?> <configuration> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> </startup> <appSettings> <add key="FtpHost" value="127.0.0.1"/> <add key="FtpUser" value="username"/> <add key="FtpPassword" value="password123"/> <add key="FtpDirectory" value="/INTERESTING FILES/DATA"/> <add key="FileExtension" value=".txt"/> <add key="DownloadTo" value="C:\Downloads"/> <add key="DeleteFilesAfterDownload" value="false"/> </appSettings> </configuration>
And a little FTP Library: