title: Read large txt file and use it in chunks
body: <p>I'm newbie in C# but I've made some research for reading/writing large txt files, the biggest might be 8GB but if it is too much I will consider split it maybe to 1GB. It must be fast up to 30MBytes/s. I've found three approaches: for sequential operation FileStream or StreamReader/StreamWriter, for random access MemoryMappedFiles.
  Now I'd like first to read file. Here is an example of code that works:</p>
  
  <pre><code> FileStream fileStream = new FileStream(@"C:\Users\Guest4\Desktop\data.txt", FileMode.Open, FileAccess.Read);
  try
  {
      int length = (int)fileStream.Length;  // get file length
      buffer = new byte[length];            // create buffer
      int count;                            // actual number of bytes read
      sum = 0;                          // total number of bytes read
  
      // read until Read method returns 0 (end of the stream has been reached)
      while ((count = fileStream.Read(buffer, sum, length - sum)) &gt; 0)
          sum += count;  // sum is a buffer offset for next reading
  }
  finally
  {
      fileStream.Close();
  }
  </code></pre>
  
  <p>Do you think is it good way to that fast big files reading?</p>
  
  <p>After reading I need to resend that file. It must be in 16384 bytes chunks. Every chunk will be sent until all the data will be transmitted. And that chunks have to be string type. Could you suggest me how to do it? Split and convert to string. I suppose the best way is to send that string chunk not after reading all file, but if at least that 16384 bytes is read. </p>