Create a .txt file if doesn’t exist, and if it does append a new line

Use the correct constructor:

else if (File.Exists(path))
{
    using(var sw = new StreamWriter(path, true))
    {
        sw.WriteLine("The next line!");
    }
}

Leave a Comment