Wednesday, 18 March 2009

Read/Write text file in C#

//read file
using (TextReader tr = new StreamReader("sample.txt"))
{
  string line = tr.ReadLine();
}
//write file
using (TextWriter tw = new StreamWriter("sample.txt"))
{
  tw.WriteLine("text");
}

No comments:

Post a Comment