title: Displaying a text file on a Windows Form for C#
body: <p>I am trying to display the content of a txt file.
  I thought I should use RichTextBox for that method. What I've done was this. However it does not work.</p>
  
  <pre><code>public static byte[] ReadFile() {
  
          FileStream fileStream = new FileStream(@"help.txt", FileMode.Open, FileAccess.Read);
          byte[] buffer;
          try {
              int length = (int)fileStream.Length;  // get file length
              buffer = new byte[length];            // create buffer
              int count;                            // actual number of bytes read
              int 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();
          }
          return buffer;
      }
  
      private void richTextBox1_TextChanged(object sender, EventArgs e) {
          ReadFile();
      }
  </code></pre>