Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Ok here is what you could try. This code is not tested. So if it contains errors and you get it work please edit answer or point me to mistakes.</p> <pre><code>static void chunkCopyFile(string source, string destination, int bytesPerChunk) { uint bytesRead = 0; //Instead of this: //using (FileStream fs = new FileStream(source, FileMode.Open, FileAccess.Read)) { //...some necessary stuff... FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://www.contoso.com/test.htm"); request.Method = WebRequestMethods.Ftp.DownloadFile; request.Credentials = new NetworkCredential ("anonymous","janeDoe@contoso.com"); FtpWebResponse response = (FtpWebResponse)request.GetResponse(); //Use this: using(Stream fs = response.GetResponseStream()){ using (BinaryReader br = new BinaryReader(fs)) { using (FileStream fsDest = new FileStream(destination, FileMode.Create)) { BinaryWriter bw = new BinaryWriter(fsDest); long cl = response.ContentLength;         int bufferSize = 2048;         int readCount;         byte[] buffer = new byte[bufferSize];       readCount = fs.Read(buffer, 0, bufferSize);         while (readCount &gt; 0)         { bw.Write(buffer, 0, readCount);             readCount = fs.Read(buffer, 0, bufferSize); updateProgress(readCount);         } } } } } </code></pre> <p>References:</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms229711" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms229711</a></p> <p><a href="http://www.codeproject.com/Articles/17202/Simple-FTP-demo-application-using-C-Net-2-0" rel="nofollow">http://www.codeproject.com/Articles/17202/Simple-FTP-demo-application-using-C-Net-2-0</a> (Download method code)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload