本文介绍了使用FTP复制大文件(300 MB以上)时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用FTP从一台服务器复制大尺寸文件(300MB或更多)时出现错误

这里是我的代码

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");
            }
        }



错误显示此

远程服务器返回错误:(550)文件不可用(例如,找不到文件,没有访问权限。。


Error shows this
The remote server returned an error: (550) File unavailable (e.g., file not found, no access).

推荐答案


这篇关于使用FTP复制大文件(300 MB以上)时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 01:31