retrieve web page to string

  • Thread starter Thread starter Al Reid
  • Start date Start date
A

Al Reid

Hi,

In VB6 I would use the Inet Control to retrieve the contents of a web page to a string. What is the .NET way of doing this?


TIA,
 
Al Reid said:
In VB6 I would use the Inet Control to retrieve the contents of a web page
to a string. What is the .NET way of doing this?

\\\
Imports System.IO
Imports System.Net
..
..
..
Public Function LoadTextFile(ByVal Url As String) As String
Dim wrq As WebRequest = WebRequest.Create(Url)
Dim wrp As HttpWebResponse = _
DirectCast(wrq.GetResponse(), HttpWebResponse)
Dim sr As New StreamReader(wrp.GetResponseStream())
Dim Text As String = sr.ReadToEnd()
sr.Close()
wrp.Close()
Return Text
End Function
///
 
Herfried,

Thanks so much.

As a newbie to .Net, I missed the System.Net and was looking at System.Web namespace. your code makes perfect sense.

--
Al Reid

"It ain't what you don't know that gets you into trouble. It's what you know
for sure that just ain't so." --- Mark Twain
 
Back
Top