file write all text c# code example
Example 1: c sharp how to read a text file
string text = System.IO.File.ReadAllText(@"C:\filepath\file.txt");
string[] lines = System.IO.File.ReadAllLines(@"C:\filepath\file.txt");
Example 2: asp.net c# write string to text file
using (StreamWriter writer = new StreamWriter("email.txt", true))
{
writer.WriteLine("your_data");
}
Example 3: write text files with C#
string createText = "Hello and Welcome" + Environment.NewLine;
File.WriteAllText(path, createText);
...
string readText = File.ReadAllText(path);