public void FTPUpload(string p_FilePath, string p_FTPServer, string p_Username, string p_Password) { try { //Reading file into a byte array byte[] file = null; file = System.IO.File.ReadAllBytes(p_FilePath); //Request System.Net.FtpWebRequest req = null; req = (System.Net.FtpWebRequest)System.Net.WebRequest.Create(p_FTPServer); req.KeepAlive = false; req.UsePassive = true; req.UseBinary = true; req.Proxy = null; //timeout set to 40 minute need to change req.Timeout = 2400000; req.ReadWriteTimeout = 2400000; //Credentials System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(p_Username, p_Password); req.Credentials = credentials; //Request Method req.Method = System.Net.WebRequestMethods.Ftp.UploadFile; //uploading file onto FTP server System.IO.Stream stream = null; stream = req.GetRequestStream(); stream.Write(file, 0, file.Length); stream.Close(); } catch (Exception ex) { Util.WriteToErrorLogFile(ex, "Error:017", "From FTP File laod of Service"); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)