read and write text file in c# code example
Example 1: write text files with C#
// Create a file to write to.
string createText = "Hello and Welcome" + Environment.NewLine;
File.WriteAllText(path, createText);
...
// Open the file to read from.
string readText = File.ReadAllText(path);
Example 2: how to read a text file C#
string[] text = System.IO.File.ReadAllLines(@"C:\users\username\filepath\file.txt");