Read data in line by line
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
class Program {
static void Main(string[] args) {
string strLine;
try {
FileStream aFile = new FileStream("Log.txt", FileMode.Open);
StreamReader sr = new StreamReader(aFile);
strLine = sr.ReadLine();
while (strLine != null) {
Console.WriteLine(strLine);
strLine = sr.ReadLine();
}
sr.Close();
} catch (IOException e) {
Console.WriteLine("An IO exception has been thrown!");
Console.WriteLine(e.ToString());
return;
}
}
}
Related examples in the same category