read data from text file in 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: c# read all text from a file
using (StreamReader streamReader = new StreamReader(path_name, Encoding.UTF8))
{
contents = streamReader.ReadToEnd();
}
Example 3: how to read a text file C#
string[] text = System.IO.File.ReadAllLines(@"C:\users\username\filepath\file.txt");