Reading file into RichTextBox without using LoadFile
<p>I want to read a file into a RichTextBox without using LoadFile (I might want to display the progress). The file contains only ASCII characters.</p>

<p>I was thinking of reading the file in chunks.</p>

<p>I have done the following (which is working):</p>

<pre><code>const int READ_BUFFER_SIZE = 4 * 1024;

BinaryReader reader = new BinaryReader(File.Open("file.txt", FileMode.Open));

byte[] buf = new byte[READ_BUFFER_SIZE];
do {
    int ret = reader.Read(buf, 0, READ_BUFFER_SIZE);
    if (ret &lt;= 0) {
        break;
    }

    string text = Encoding.ASCII.GetString(buf);
    richTextBox.AppendText(text);
} while (true);
</code></pre>

<p>My concern is:</p>

<pre><code>string text = Encoding.ASCII.GetString(buf);
</code></pre>

<p>I have seen that it is not possible to add a <code>byte[]</code> to a RichTextBox.</p>

<p>My questions are:</p>

<ul>
<li><p>Will a new string object be allocated for every chunk which is read?</p></li>
<li><p>Isn't there a better way not to have to create a string object just for appending the text to the RichTextBox?</p></li>
<li><p>Or, is it more efficient to read lines from the file (StreamReader.ReadLine) and just add to the RichTextBox the string returned?</p></li>
</ul>
