new StreamReader(FileStream fs)
using System;
using System.IO;
class MainClass {
public static void Main(string[] args) {
try {
FileStream fs = new FileStream("c:\\a.txt", FileMode.Open);
StreamReader sr = new StreamReader(fs);
string line = "";
int lineNo = 0;
do {
line = sr.ReadLine();
if (line != null) {
Console.WriteLine("{0}: {1}", lineNo, line);
lineNo++;
}
} while (line != null);
} catch (Exception e) {
Console.WriteLine("Exception in ShowFile: {0}", e);
}
}
}
Related examples in the same category