Mai Hu Na

Mai Hu Na

  • NA
  • 86
  • 130.9k

Error while copying large files(300 MB more) using FTP

Jul 18 2013 9:24 AM
I got Error while copying large size file(300MB or more) from one server to another using FTP
here is my code
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");
}
}
Error shows this
The remote server returned an error: (550) File unavailable (e.g., file not found, no access).