C# - Loading a large file into a WPF RichTextBox?
I need to load a ~ 10MB range text file into a WPF RichTextBox, but my current code is freezing up the UI. I tried making a background worker do the loading, but that doesnt seem to work too well either. Here's my loading code. Is there any way to improve its performance? Thanks. //works well for small files only private void LoadTextDocument(string fileName, RichTextBox rtb) { System.IO.StreamReader objReader = new StreamReader(fileName); if (File.Exists(fileName)) { rtb.AppendText(objReader.ReadToEnd()); } else rtb.AppendText("ERROR: File not found!"); objReader.Close(); } //background