how to text of file c# code example
Example 1: c# read all text from a file
using (StreamReader streamReader = new StreamReader(path_name, Encoding.UTF8))
{
contents = streamReader.ReadToEnd();
}
Example 2: how to call last string from text file C#
If the file is not too large, just read the lines and pick the last:
string lastLine = File.ReadLines("pathToFile").LastOrDefault();