Example of using a Fluent FTP Client;
using FluentFTP;
#region Put it to location
if (AppSettings.Get<string>("FTP.N.URI") != "")
{
client = new FtpClient(AppSettings.Get<string>("FTP.N.URI"));
client.Credentials = new NetworkCredential(AppSettings.Get<string>("FTP.USERNAME"), AppSettings.Get<string>("FTP.PASSWORD"));
client.Connect();
client.RetryAttempts = 1;
//
string nFile = Path.Combine(AppSettings.Get<string>("FTP.N.PATH"), filename);
string nFileOld = nFile.Replace(Path.GetExtension(nFile), ".old");
if (client.FileExists(nFile))
{
client.UploadFile(ExportFileInternal, nFile, FtpExists.Overwrite, false, FtpVerify.Retry);
log("HTML Report replaced: " + Path.Combine(AppSettings.Get<string>("FTP.N.URI"), nFile));
client.UploadFile(ExportFileInternal, nFileOld, FtpExists.Overwrite, false, FtpVerify.Retry);
log("Old file replaced: " + Path.Combine(AppSettings.Get<string>("FTP.N.URI"), nFileOld));
}
else
{
client.UploadFile(ExportFileInternal, nFile, FtpExists.Overwrite, false, FtpVerify.Retry);
log("HTML Report replaced: " + Path.Combine(AppSettings.Get<string>("FTP.N.URI"), nFile));
}
client.Disconnect();
}
#endregion