string path = @"C:\txtFile.txt";
string rawText = System.IO.File.ReadAllText(path);
string body = Regex.Replace(rawText, @"(?:\r\n *){1,2} *", "<br />");
OR:-
string[] lines = rawText.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None); // alternative replace \r\n with <br />
StringBuilder body = new StringBuilder();
foreach (string line in lines)
{
body.AppendLine(String.Format("{0}{1}", line, "<br />"));
}
string rawText = System.IO.File.ReadAllText(path);
string body = Regex.Replace(rawText, @"(?:\r\n *){1,2} *", "<br />");
OR:-
string[] lines = rawText.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None); // alternative replace \r\n with <br />
StringBuilder body = new StringBuilder();
foreach (string line in lines)
{
body.AppendLine(String.Format("{0}{1}", line, "<br />"));
}