protected void UploadToFTP(string path, string name)
{
Logger("Executing UploadToFTP Function . . .");
Logger("UploadToFTP Report :: " + path + "," + name);
String sourcefilepath = path;
String ftpurl = "ftp://cnetiran.com";
String ftpusername = "cnetiran.com";
String ftppassword = "************";
try
{
string filename = Path.GetFileName(sourcefilepath);
string ftpfullpath = ftpurl + "//rasool//" + name;
FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(ftpfullpath);
ftp.Credentials = new NetworkCredential(ftpusername, ftppassword);
ftp.KeepAlive = true;
ftp.UseBinary = true;
ftp.Method = WebRequestMethods.Ftp.UploadFile;
FileStream fs = File.OpenRead(sourcefilepath);
byte[] buffer = new byte[fs.Length];
fs.Read(buffer, 0, buffer.Length);
fs.Close();
Stream ftpstream = ftp.GetRequestStream();
ftpstream.Write(buffer, 0, buffer.Length);
ftpstream.Close();
}
catch (Exception ex)
{
Logger("UploadToFTP Function Says : " + ex.ToString());
}
Logger("End of UploadToFTP . . .");
}