Logo 
Search:

Asp.net Answers

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds
  Question Asked By: Reginheraht Fischer   on Sep 25 In Asp.net Category.

  
Question Answered By: Corbin Jones   on Sep 25

Try this function - Just stick it in a label and you are on your way.


Function readfile(ByVal contentRequest As String) As String

Trace.Warn("Requested: ", contentRequest)

Dim FILENAME As String = Server.MapPath("/pplContent/" & contentRequest &
".txt")

Trace.Write(FILENAME)

'Dim FILENAME As String = "Rand.txt"

'Get a StreamReader class that can be used to read  the file

Dim objStreamReader As StreamReader

Try

objStreamReader = File.OpenText(FILENAME)

Dim contents As String = objStreamReader.ReadToEnd()

lblNicerOutput.Text = contents.Replace(vbCrLf, "<br>")

Catch

lblNicerOutput.Text = "<h3>Sorry that file  can not be located</h3>"

End Try

'We may wish to replace carraige returns with <br>s



objStreamReader.Close()

End Function

Share: 

 

This Question has 3 more answer(s). View Complete Question Thread

 


Tagged: