Newbie: text files

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

A CRLF does not render in the broswer as a break/line feed, you'll have to
read the file into a string var and replace crlf with "<BR>"... HTH
 
Chris said:
This solution has the same problem as using response.writefile. The CRLF
fields don't display.

Chris

Dim sr As System.IO.StreamReader = New
System.IO.StreamReader("TextFile.txt")
Response.Write(sr.ReadToEnd().Replace(vbNewLine, "<br>")

Hope this helps :)

Mythran
 
Sorry if this is a simple question. I have a bunch of text files that I am
allowing I want to display on my web page. When I do a response.writefile
to load the file the CRLFs don't work. How can show the contents of the
text file to the user easily?

Thanks
Chris
 
This solution has the same problem as using response.writefile. The CRLF
fields don't display.

Chris
 
As well as replacing the line breaks with <br /> tags you will want to
Server.HtmlEncode all of your text. Not doing so can cause security problems
if you allow people to upload files. Even if you don't allow people to
upload files, Html encoding the text is a good idea so that everything
displays correctly.
 

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

Back
Top