【问题标题】:vb.NET Network.UploadFile Limitvb.NET Network.UploadFile 限制
【发布时间】:2013-02-22 17:21:05
【问题描述】:

我使用 My.Computer.Network.UploadFile 方法将文件上传到 FTP 。 但我有一些问题。我的问题是上传速度。

例如:我使用一些 FTP 程序 (FileZilla),上传速度为 4 Mb/sn。 但是 My.Computer.Network.UploadFile 方法是 1.20Mb/sn 限制。

为什么这种方法是有限的?我可以提高上传速度吗?

【问题讨论】:

    标签: vb.net upload limit


    【解决方案1】:

    使用此代码朋友并告诉我这是否有用:

            using System.Net;
                 // Get the object used to communicate with the server.
                FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create("ftp://
                XXXXXXXXXXXXXXXXXXXXX/" + "C:/XXXXX.zip");
                request.Method = WebRequestMethods.Ftp.UploadFile;
                request.Credentials = new NetworkCredential("User", "PassWord");
    
                // Copy the contents of the file to the request stream.
                Stream ftpStream = request.GetRequestStream();
                FileStream file = File.OpenRead("C:/XXXXX.zip");
    
                int length = 1024;
                byte[] buffer = new byte[length];
                int bytesread = 0;
    
                do
                {
                bytesread = file.Read(buffer,0,length);
                ftpStream.Write(buffer,0,bytesread);
                }
                while(bytesread != 0);
    
                file.Close();
                ftpStream.Close();
    
                MessageBox.Show("Uploaded Successfully");
    

    【讨论】:

    • FtpWebRequest 的速度是 700-800 kb/sn 。任何的想法 ?也许 app.config 编辑?
    • 如果这些选项改变了结果,请通知我(其中一些绑定到您的 FTP 服务器配置) Request.UseBinary = true; Request.UsePassive = true; Request.KeepAlive = true;
    • 未更改 (700-800 kb-sn)。它非常有趣。我现在使用 ftp.exe,速度为 4 - 6 mb/sn。
    猜你喜欢
    • 2011-05-17
    • 1970-01-01
    • 2012-09-15
    • 1970-01-01
    • 1970-01-01
    • 2010-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多