Read text file line by line
using System;
using System.IO;
public class ReadWriteApp
{
public static void Main(string[] args)
{
FileStream s = new FileStream("Bar.txt", FileMode.Create);
StreamWriter w = new StreamWriter(s);
w.Write("Hello World");
w.Close();
s = new FileStream("Bar.txt", FileMode.Open);
StreamReader r = new StreamReader(s);
string t;
while ((t = r.ReadLine()) != null)
{
Console.WriteLine(t);
}
w.Close();
}
}
Related examples in the same category