Open existing file, append a single line

Blankman picture Blankman · May 14, 2010 · Viewed 294.4k times · Source

I want to open a text file, append a single line to it, then close it.

Answer

Fredrik Mörk picture Fredrik Mörk · May 14, 2010

You can use File.AppendAllText for that:

File.AppendAllText(@"c:\path\file.txt", "text content" + Environment.NewLine);