Fastest way to store an ascii file's text in a RichTextBox?
I have some ascii files that are 60-100MB in size. I want to store one of these in a control in Visual C# as quickly as possible. I've been googling for answers and I've found a few solutions such as putting the file into a stringbuilder and then converting that to a string and storing it in the rtb. The solution I have found thus far uses a a filestream and does txt_log.LoadFile(fi, Rich开发者_高级运维TextBoxStreamType.PlainText). This is the fastest implementation thus far but a better implementation must exist. Is there something else I'm overlooking? Is there a way to make the RTB dynamically page the file directly?
If it helps, I plan to read through the file to perform searches after I load it.
I imagine a simple way would be to do:
myRtb.Text = File.ReadAllText(bigFile.txt, Encoding.ASCIIEncoding);
but it's doubtful you'd get good performance out of it with such a huge file.
精彩评论