Hello All
i am trying to read a large txt files -may 1 GB-, which coze my program to
hang, and i need to know if there are techniques that make this without hang
and do it faster
if you know something can help. please tell me.
that is my code , and i had run it for a txt file its size is 423 MB, and i
left my PC opened and in the next day i found that it records about 10 hours
and large number of lines about 500000 line and also i got an exception
"OutOfMemoryExc eption"
and i dont know much about "backgroundwork er", if you know a complete
example plz provid me by the link
StreamReader SR;
private void btnReadFile_Cli ck(object sender, EventArgs e)
{
DateTime DT= DateTime.Now;
TimeSpan T = new TimeSpan(DT.Day , DT.Hour, DT.Minute, DT.Second);
if (SR != null)
{
while (!SR.EndOfStrea m)
{
try
{
string line = SR.ReadLine();
txtFileContent. AppendText(line );
txtFileContent. AppendText("\n" );
txtFileContent. AppendText("\r" );
int count = Convert.ToInt32 (labNumOfLines. Text);
count++;
labNumOfLines.T ext = count.ToString( );
DateTime tempTime = DateTime.Now;
TimeSpan T2 = new TimeSpan(tempTi me.Day, tempTime.Hour, tempTime.Minute ,
tempTime.Second );
T2=T2.Subtract( T);
labTime.Text = T2.ToString();
this.Refresh();
}
catch(Exception ex)
{
MessageBox.Show (ex.Message);
}
}
}
}
Note:txtFileCon tent is a TextBox