public static bool UploadFile(string _sourcefile, string _targetfile, string _user, string _pass)
{
bool up = false;
try
{
System.Net.FtpWebRequest ftp = (System.Net.FtpWebRequest)System.Net.FtpWebRequest.Create(_targetfile);
ftp.Credentials = new System.Net.NetworkCredential(_user, _pass);
//userid and password for the ftp server to given
ftp.UseBinary = true;
ftp.UsePassive = true;
ftp.EnableSsl = Core.Global.GetConfig().ConfigFTPSSL;
ftp.Method = System.Net.WebRequestMethods.Ftp.UploadFile;
System.IO.FileStream fs = System.IO.File.OpenRead(_sourcefile);
byte[] buffer = new byte[fs.Length];
fs.Read(buffer, 0, buffer.Length);
fs.Close();
System.IO.Stream ftpstream = ftp.GetRequestStream();
ftpstream.Write(buffer, 0, buffer.Length);
ftpstream.Close();
ftp.Abort();
up = true;
}
catch (Exception ex)
{
Core.Log.WriteLog(ex.ToString(), true);
}
return(up);
}