• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2172
  • Last Modified:

WPF - Virtual Textbox to load large text file

Hello Experts,

I'm loading a large text file (5mb) into a richtextbox.  However it is very slow to load.  The line below is taking too long.

              TextRange range = new TextRange(PART_RichTextBox1.Document.ContentStart, PART_RichTextBox1.Document.ContentEnd);                            
range.Load(textStream, GetFileDataFormat(this.ViewModel.GetFileType()));  


How can I the improve performance?  

Thanks,
Steve
0
OFGemini
Asked:
OFGemini
1 Solution
 
cubaman_24Commented:
Hello:
Try using Memory-Mapped Files to avoid loading the full file at startup. Then, you can load only the text that fits in the visible area of the textbox, and do sequential access to the memory mapped file when scroll is done in the textbox.
Hope this helps.

http://msdn.microsoft.com/en-us/library/dd997372.aspx
0
 
OFGeminiAuthor Commented:
Thanks.  I'll try to implement this
0
 
sahana talankiCommented:
Where you successful in this implementation? I have similar challenges in my application. Please help.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now