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");
}

Comments

Popular posts from this blog

Parse XML to dynamic object in C#

C# Crop white space from around the image