Simple and easy way to read and write text to a file in C#


Simple and straight forward way to read and write text from a text file.

 static void Main(string[] args)
        {
            // Read from text file
            var text = File.ReadAllText(@"C:\file.txt");
 
            // Write text from text file
            File.WriteAllText(@"C:\file.txt", text   "New Text");
        }