Mai Hu Na

Mai Hu Na

  • NA
  • 86
  • 132.7k

Load large files using ftp in c# code

Mar 6 2013 9:22 AM
hi all,
         i am working on loading large files of size 200 mb or more sizes  to one server to another but it gives Error
              "The remote server returned an error: (550) File unavailable (e.g., file not found, no access)."
       
        please help me my function to load files is
       
       FTPUpload(string FilePath, string FTPServer, string Username, string Password)
        (
              //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);


                //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();
        )
     please help..Thanks

Answers (3)