I am trying to read a file I create that contains all the logs lines throughout my program. I have the following cod:
private string ReadEmailLog(string EmailLog)
{
TextReader tr = new StreamReader(EmailLog);
tr.ReadLine();
tr.Close();
}
I need to read the EmailLog file, every line of it, and then put return it into a string called message. How would I get this method to return the whole log file, every line?
You can use
File.ReadAllTextorFile.ReadAllLines.If you’re using .NET 4.0, you can also use
File.ReadLines:This allows you to make file I/O part of a LINQ operation.