Appending text to a file in C#

You can append text to a existing file by the following example.
If the file does not exist then the file will be generated and the text will be written.

using System;
using System.IO;

namespace forgetCode
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Please enter the content to append in to the file - type exit and press enter to finish editing:");
            string newContent = Console.ReadLine();
            while (newContent != "exit")
            {
                File.AppendAllText("D:\\test.txt", newContent);
                newContent = Console.ReadLine();
            }

        }
    }
}


Output:
The entered text will be written into a file in the path - D:\\test.txt

..