Use namespace System.IO
VB.NET
Dim sr As StreamReader
sr = File.OpenText(Server.MapPath('1.txt'))
Dim strContents As String = sr.ReadToEnd()
’To display normal raw contents
Response.Write(strContents)
’To handle Carriage returns
Response.Write(strContents.Replace(vbCrLf, '<br>'))
sr.Close()
C#
StreamReader sr = File.OpenText(Server.MapPath('1.txt'));
string strContents = sr.ReadToEnd();
//To display normal raw contents
Response.Write(strContents);
//To handle Carriage returns
Response.Write(strContents.Replace('\n' , '<br>'));
sr.Close();
Share with