string txt file c# code example
Example 1: asp.net c# write string to text file
using (StreamWriter writer = new StreamWriter("email.txt", true)) //// true to append data to the file
{
writer.WriteLine("your_data");
}
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();