Hello,
I am trying to read in a large text file (2-6 gig), parse what I need and write it out to a smaller text file which is about 20% of the size of the original. The problem is in this read/write and amount of memory the program uses just keeps growing and growing until with a 4 gig or larger input file the program will crash. The error I usually get is something about not having MDAC 2.6 (I have 2.81), so that doesn't make sense to me.
Here is the basic code I am using. I hoping someone has a better way of doing this that will not cause the memory growth. Thanks for your help.
I am trying to read in a large text file (2-6 gig), parse what I need and write it out to a smaller text file which is about 20% of the size of the original. The problem is in this read/write and amount of memory the program uses just keeps growing and growing until with a 4 gig or larger input file the program will crash. The error I usually get is something about not having MDAC 2.6 (I have 2.81), so that doesn't make sense to me.
Here is the basic code I am using. I hoping someone has a better way of doing this that will not cause the memory growth. Thanks for your help.
Code:
using (StreamWriter swOut = fiOut.CreateText())
{
if (fi.Exists)
{
using (StreamReader sr = fi.OpenText())
{
string input = null;
string output = null;
while ((input = sr.ReadLine()) != null)
{
//
// parse the input and create the output line here
//
swOut.WriteLine(output);
count++;
}
}
}
}