Hi,
am creating a web app in asp.net. How do I bring text from a file into a label and display it.
code I currently have...
Dim sr As System.IO.StreamReader
Dim filename As String = "C:\Documents and Settings\myusername\StreamReader.txt"
sr = file.OpenText(filename)
Dim contents As String = sr.ReadToEnd()
lblStreamReader.Text = contents
sr.Close()
but I'm missing something. there is a problem with the line:
sr = file.OpenText(filename)
any help would be much appreciated!found the solution. so here's what I got, in case others have a similar problem/question. Its not complicated, but you just need to know what to look for I guess.
Dim Contents As String
Dim sr As System.IO.StreamReader
sr = New System.IO.StreamReader("C:\Documents and Settings\StreamReader.txt")
Contents = objReader.ReadToEnd()
sr.Close()
lblStreamReader.Text = ContentsI did something like that before, but into a combo box.
I used a variable LineOfText and a loop Do until EOF(name of file), then LineOfText = LineInput(nameOfFile)
But I think it might be the same in a different way.
am creating a web app in asp.net. How do I bring text from a file into a label and display it.
code I currently have...
Dim sr As System.IO.StreamReader
Dim filename As String = "C:\Documents and Settings\myusername\StreamReader.txt"
sr = file.OpenText(filename)
Dim contents As String = sr.ReadToEnd()
lblStreamReader.Text = contents
sr.Close()
but I'm missing something. there is a problem with the line:
sr = file.OpenText(filename)
any help would be much appreciated!found the solution. so here's what I got, in case others have a similar problem/question. Its not complicated, but you just need to know what to look for I guess.
Dim Contents As String
Dim sr As System.IO.StreamReader
sr = New System.IO.StreamReader("C:\Documents and Settings\StreamReader.txt")
Contents = objReader.ReadToEnd()
sr.Close()
lblStreamReader.Text = ContentsI did something like that before, but into a combo box.
I used a variable LineOfText and a loop Do until EOF(name of file), then LineOfText = LineInput(nameOfFile)
But I think it might be the same in a different way.