Wow, looking at your code it looks like you started vb.net with some old fashioned basic experience.
- You could use a
While
for looping which improves readability.
-
Catch ex As Exception
is hiding information
Most performance loss is in lines like these:
DATABASE = DATABASE & vbCrLf & lines(x).ToString
Each time the old string object DATABASE is copied to a new string object including the addition of a line end and a line. Very inefficient. Use a StringBuilder instead.
http://msdn.microsoft.com/en-us/library/system.text.stringbuilder.aspx#Y0[
^]
For more info, check this:
Performance considerations for strings in C#[
^]
Try reading the file once and in blocks to avoid overuse of memory.
Added a link, but also try google.
http://stackoverflow.com/questions/8243538/reading-and-parsing-large-delimited-text-files-in-vb-net[
^]
You could also check this out:
http://www.filehelpers.com/[
^]
Good luck!