c# read text file to string code example
Example 1: read text file to string c#
string mystring = System.IO.File.ReadAllText(@"C:\Users\Public\TestFolder\WriteText.txt");
Example 2: read file c#
string text = File.ReadAllText(@"c:\file.txt", Encoding.UTF8);
Example 3: c# read all text from a file
using (StreamReader streamReader = new StreamReader(path_name, Encoding.UTF8))
{
contents = streamReader.ReadToEnd();
}
Example 4: c# read file into a string
string mystring = File.ReadAllText(your_file_location, Encoding.UTF8);