At first I used a StreamReader
to read text from a file:
StreamReader reader = new StreamReader(dialog.OpenFile());
txtEditor.Text = reader.Read
Looking at the code within mscorlib, File.ReadAllText actually calls StreamReader.ReadToEnd internally!
[SecurityCritical]
private static string InternalReadAllText(string path, Encoding encoding, bool checkHost)
{
string result;
using (StreamReader streamReader = new StreamReader(path, encoding, true, StreamReader.DefaultBufferSize, checkHost))
{
result = streamReader.ReadToEnd();
}
return result;
}