Read file to the end : File Read « File Directory « ASP.Net






Read file to the end

<%@ Page Language="vb" %>
<html>
   <head>
      <title>Unload event example</title>
      <script runat="server">
         Dim TheFile As System.IO.StreamReader
         Sub Page_Load()
            TheFile = System.IO.File.OpenText(MapPath("file.txt"))
            Message.Text = "<pre>" & _
               Server.HtmlEncode(TheFile.ReadToEnd()) & "</pre>"
         End Sub
         Sub Page_Unload()
            TheFile.Close()
         End Sub
      </script>
   </head>
<body>
   <asp:label id="Message" runat="server"/>
</body>
</html>
           
       








Related examples in the same category