I have to read line-by-line a log file. It's about 6MB in size and 40000 line total. But after testing my program, I discover that that log file is only delimited by LF character only. So I can't use the Readline
method of StreamReader
class
How can I fix this problem?
edit: I tried to use Text Reader, but my program still didn't work:
using (TextReader sr = new StreamReader(strPath, Encoding.Unicode))
{
sr.ReadLine(); //ignore three first lines of log file
sr.ReadLine();
sr.ReadLine();
int count = 0; //number of read line
string strLine;
while (sr.Peek()!=0)
{
strLine = sr.ReadLine();
if (strLine.Trim() != "")
{
InsertData(strLine);
count++;
}
}
return count;
}