Try
' Create an instance of StreamReader to read from a file.
Dim sr As StreamReader = New StreamReader("TestFile.txt")
Dim line As String
' Read and display the lines from the file until the end
' of the file is reached.
Do
line = sr.ReadLine()
Console.WriteLine(Line)
Loop Until line Is Nothing
sr.Close()
Catch E As Exception
' Let the user know what went wrong.
Console.WriteLine("The file could not be read:")
Console.WriteLine(E.Message)
End Try
"Mark" <me@here.com> wrote in message
news:el**************@TK2MSFTNGP11.phx.gbl...
For purposes of sending the contents of a file to a function that requires
a string, I am trying to find a way to read a file to a string variable &
pass it along.
For example, if the file text.txt contained "this is a test" I couldn't
just do this:
strVar = "text.txt"
because the string variable would obviously represent just the filename &
not it's contents.
I am sorry if this is very simple, but of course I'm new to VB (& ASP) and
any suggestions would be great.
Thanks.