Read data from text file (C#) : Write File « Response « ASP.Net






Read data from text file (C#)

<%@ Page Language="C#" %>
<html>
<head>
   <title>Simple ASP.NET Page</title>
</head>
<body>

<% 

System.IO.StreamReader sr = new System.IO.StreamReader("/file.txt");
string line;

while(sr.Peek() != -1)
{
   line = sr.ReadLine();
   Response.Write(Server.HtmlEncode(line) + "<br/>");
}

%>

</body>
</html>
           
       








Related examples in the same category

1.Writing a file to output (VB.net)
2.Read file and display its content on the page (VB.net)
3.Write file (C#)