Search This Blog

Thursday, September 24, 2015

Appends text to a file C#

C# > Files > File Class > AppendText

Appends text to an existing file or create a new file if the specified file does not exist.

Example

using(System.IO.StreamWriter sw = System.IO.File.AppendText(@"c:\log.txt"))
{
      sw.WriteLine("logline");
}