Read file using StreamReader (VB.net) : StreamReader « File Directory « ASP.NET Tutorial






<%@ Page Language="VB" %>
<%@ Import namespace="System.IO" %>

<script runat="server">
   sub DisplayFile(Sender as Object, e as EventArgs)
      dim strFile as string = tbFile.Text
      dim objReader as StreamReader
      
      if File.Exists(strFile) then
         objReader = new StreamReader(strFile)
            
         while objReader.Peek > -1
            lblMessage.Text += Server.HTMLEncode _
               (objReader.ReadLine) & "<br>"
         end while
            
         objReader.Close
      end if
   end sub
</script>

<html><body>
   <form runat="server">
      <asp:TextBox id="tbFile" runat="server"
         OnTextChanged="DisplayFile"
         AutoPostBack=true />
      
      <asp:Label id="lblMessage" runat="server"
         MaintainState=false/>
   </form>
</body></html>








10.18.StreamReader
10.18.1.Read file using StreamReader (VB.net)
10.18.2.Create StreamReader from IsolatedStorageFileStream (VB.net)