Use map path (VB.net) : Map Path « Server « ASP.Net






Use map path (VB.net)

<%@ 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

1.Showing ServerVariable values via the ServerVariables Collection in ASP.NET
2.MapPath(file) (VB.net)