<legend id='LZwZl'><style id='LZwZl'><dir id='LZwZl'><q id='LZwZl'></q></dir></style></legend>

    <i id='LZwZl'><tr id='LZwZl'><dt id='LZwZl'><q id='LZwZl'><span id='LZwZl'><b id='LZwZl'><form id='LZwZl'><ins id='LZwZl'></ins><ul id='LZwZl'></ul><sub id='LZwZl'></sub></form><legend id='LZwZl'></legend><bdo id='LZwZl'><pre id='LZwZl'><center id='LZwZl'></center></pre></bdo></b><th id='LZwZl'></th></span></q></dt></tr></i><div id='LZwZl'><tfoot id='LZwZl'></tfoot><dl id='LZwZl'><fieldset id='LZwZl'></fieldset></dl></div>
  • <small id='LZwZl'></small><noframes id='LZwZl'>

        <tfoot id='LZwZl'></tfoot>
          <bdo id='LZwZl'></bdo><ul id='LZwZl'></ul>
      1. C#:FTP 上传缓冲区大小

        时间:2023-06-04

          • <bdo id='01U31'></bdo><ul id='01U31'></ul>
          • <small id='01U31'></small><noframes id='01U31'>

              <tbody id='01U31'></tbody>

            <tfoot id='01U31'></tfoot><legend id='01U31'><style id='01U31'><dir id='01U31'><q id='01U31'></q></dir></style></legend>

            • <i id='01U31'><tr id='01U31'><dt id='01U31'><q id='01U31'><span id='01U31'><b id='01U31'><form id='01U31'><ins id='01U31'></ins><ul id='01U31'></ul><sub id='01U31'></sub></form><legend id='01U31'></legend><bdo id='01U31'><pre id='01U31'><center id='01U31'></center></pre></bdo></b><th id='01U31'></th></span></q></dt></tr></i><div id='01U31'><tfoot id='01U31'></tfoot><dl id='01U31'><fieldset id='01U31'></fieldset></dl></div>
                  本文介绍了C#:FTP 上传缓冲区大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我已经使用了 FTP 上传功能,但是我想问一些问题这是缓冲区大小,我将其设置为 20KB 这是什么意思,如果我增加/减少它会有所不同吗?

                  I have go that FTP Upload function , but there is something that i want to ask about It is the Buffer size , i set it to 20KB what does it mean and would it make difference if i increased/decreased it ?

                      private void Upload(string filename)
                      {
                          FileInfo fi = new FileInfo(filename);
                  
                          FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create("ftp://" + textBox1.Text + "/" + Path.GetFileName(filename));
                          ftp.Credentials = new NetworkCredential(textBox2.Text, textBox3.Text);
                          ftp.Method = WebRequestMethods.Ftp.UploadFile;
                          ftp.UseBinary = true;
                          ftp.KeepAlive = false;
                          ftp.ContentLength = fi.Length;
                  
                          // The buffer size is set to 20kb
                          int buffLength = 20480;
                          byte[] buff = new byte[buffLength];
                          int contentLen;
                  
                          //int totalReadBytesCount = 0;
                  
                          FileStream fs = fi.OpenRead();
                  
                          try
                          {
                              // Stream to which the file to be upload is written
                              Stream strm = ftp.GetRequestStream();
                  
                              // Read from the file stream 2kb at a time
                              contentLen = fs.Read(buff, 0, buffLength);
                  
                              // Till Stream content ends
                              while (contentLen != 0)
                              {
                                  // Write Content from the file stream to the 
                                  // FTP Upload Stream
                                  strm.Write(buff, 0, contentLen);
                                  contentLen = fs.Read(buff, 0, buffLength);
                              }
                  
                              // Close the file stream and the Request Stream
                              strm.Close();
                              fs.Close();
                  
                          }
                          catch (Exception ex)
                          {
                              MessageBox.Show(ex.Message, "Upload Error");
                          }
                      }
                  

                  推荐答案

                  对于桌面系统上的 FTP,大约 256Kb 的块大小在我们的测试中产生了最佳性能.较小的缓冲区大小会显着降低传输速度.我建议您自己进行一些测量,但是 20Kb 对于缓冲区来说绝对太少了.

                  For FTP on desktop systems block size of about 256Kb produced the best performance in our tests. Small buffer sizes decrease speed of transfer significantly. I recommend that you do some measurements yourself, but 20Kb is definitely too little for a buffer.

                  这篇关于C#:FTP 上传缓冲区大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:打开 FTP 位置的文件对话框 下一篇:压缩目录并上传到 FTP 服务器,而无需在 C# 中本

                  相关文章

                  最新文章

                1. <i id='VPTJi'><tr id='VPTJi'><dt id='VPTJi'><q id='VPTJi'><span id='VPTJi'><b id='VPTJi'><form id='VPTJi'><ins id='VPTJi'></ins><ul id='VPTJi'></ul><sub id='VPTJi'></sub></form><legend id='VPTJi'></legend><bdo id='VPTJi'><pre id='VPTJi'><center id='VPTJi'></center></pre></bdo></b><th id='VPTJi'></th></span></q></dt></tr></i><div id='VPTJi'><tfoot id='VPTJi'></tfoot><dl id='VPTJi'><fieldset id='VPTJi'></fieldset></dl></div>

                  <small id='VPTJi'></small><noframes id='VPTJi'>

                    • <bdo id='VPTJi'></bdo><ul id='VPTJi'></ul>
                    <legend id='VPTJi'><style id='VPTJi'><dir id='VPTJi'><q id='VPTJi'></q></dir></style></legend>

                    <tfoot id='VPTJi'></tfoot>