Reputation: 31
In .net I'm coding an app that needs to read large txt files, such as 10 mb. My problem is reading files using StreamReader and doing some string manipulation, and then adding the results to a list box.
If I use threading or a background worker, processing becomes very slow. I also tried using string builder but with same result.
Any solutions for this?
Upvotes: 2
Views: 350
Reputation: 15813
You can read a 10 mb text file very quickly using ReadAllLines:
Dim ss() As String
ss = System.IO.File.ReadAllLines(filename)
Then you can manipulate the strings in the array, ss
in this case.
When you update the ListBox, you should use .BeginUpdate and .EndUpdate to make that part faster.
You can put Application.DoEvents in the loop to allow Windows messages to be processed. This may keep it from looking so much like the system is locked up.
Upvotes: 1