Home All Groups Group Topic Archive Search About

Reading a file with StreamReader and displaying its contents

Author
10 Jan 2006 9:15 PM
Chumley Walrus
I'm trying to read a text file on my aspx page, but when I do the
following, I get a line that just says "System.IO.StreamReader " at the
point of where I want the file's contents to be displayed:

<%Dim strInput As StreamReader =
File.OpenText("c:\inetpub\wwwroot\home\myfile.txt")
Dim filename As String

If File.Exists("c:\inetpub\wwwroot\home\myfile.txt") = True Then
Do While strInput.Peek() >= 0
filename = strInput.ReadLine()
Loop
response.write(strInput)
strInput.Close()
End If       %>

??
chum

Author
10 Jan 2006 9:36 PM
Jesús López
Dim strInput As StreamReader =
File.OpenText("c:\inetpub\wwwroot\home\myfile.txt")
If File.Exists("c:\inetpub\wwwroot\home\myfile.txt") = True Then
Do While strInput.Peek() >= 0
    response.write( strInput.ReadLine() )
Loop
strInput.Close()
End If
Author
11 Jan 2006 10:26 AM
Rahul Arora
Hi Chumley...

you can modify your do while loop a bit

Do While strInput.Peek() >= 0
filename = strInput.ReadLine()
response.write(strInput)
Loop
strInput.Close()


Rahul Arora

AddThis Social Bookmark Button