title: C#: FileStream.Read() doesn't read the file up to the end, but returns 0
body: <p>Here is how i do it:</p>
  
  <pre><code>static void Main(string[] args)
  {
      string FileName = "c:\\error.txt";
      long FilePosition = 137647;
  
      FileStream fr = new FileStream(FileName, FileMode.Open);
      byte[] b = new byte[1024];
      string data = string.Empty;
      fr.Seek(FilePosition, SeekOrigin.Begin);
      UTF8Encoding encoding = new UTF8Encoding();
  
      while (fr.Read(b, 0, b.Length) &gt; 0)
      {
          data += encoding.GetString(b);
      }
      fr.Close();
      string[] str = data.Split(new string[] { "\r\n" }, StringSplitOptions.None);
      foreach (string s in str)
      {
          Console.WriteLine(s);
      }
      Console.ReadKey();
  }
  </code></pre>
  
  <p>The str array ends with these lines:</p>
  
  <blockquote>
    <p>***** History for hand T5-2847880-18 (TOURNAMENT: S-976-46079) *****<br>
    Start hand: Tue Aug 11 18:14</p>
  </blockquote>
  
  <p>but there are more lines in the file.</p>
  
  <p>I've uploaded error.txt to sendspace: <a href="http://www.sendspace.com/file/5vgjtn" rel="nofollow noreferrer">http://www.sendspace.com/file/5vgjtn</a>
  And here is the full console output: the_same_site/file/k05x3a</p>
  
  <p>Please help! I'm really clueless here.
  Thanks in advance!</p>