title: How to read file by chunks
body: <p>I'm a little bit confused aboot how i should read large file(> 8GB) by chunks in case each chunk has own size.</p>
  
  <p>If I know chunk size it looks like code bellow:</p>
  
  <pre><code>using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, ProgramOptions.BufferSizeForChunkProcessing))
  {
      using (BufferedStream bs = new BufferedStream(fs, ProgramOptions.BufferSizeForChunkProcessing))
      {
          byte[] buffer = new byte[ProgramOptions.BufferSizeForChunkProcessing];
          int byteRead;
          while ((byteRead = bs.Read(buffer, 0, ProgramOptions.BufferSizeForChunkProcessing)) &gt; 0)
          {
              byte[] originalBytes;
              using (MemoryStream mStream = new MemoryStream())
              {
                  mStream.Write(buffer, 0, byteRead);
                  originalBytes = mStream.ToArray();
              }
          }
      }
  }
  </code></pre>
  
  <p>But imagine, I've read large file by chunks made some coding with each chunk(chunk's size after that operation has been changed) and written to another new file all processed chunks. And now I need to do the opposite operation. But I don't know exactly chunk size. I have an idea. After each chunk has been processed i have to write new chunk size before chunk bytes. Like this:</p>
  
  <pre><code>Number of block bytes
  Block bytes
  Number of block bytes
  Block bytes
  </code></pre>
  
  <p>So in that case first what i need to do is read chunk's header and learn what is chunk size exactly. I read and write to file only byte arrays. But I have a question - how should look chunk's header ? May be header have to contain some boundary ? </p>