Reading a file with StreamReader and displaying its contents

C

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
 
J

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
 
R

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top