Read .txt from http://

Lydecker

New member
Joined
Jul 1, 2003
Messages
4
I want to read in a .txt file from the internet, however my current code for reading in a .txt from a local drive is not compatible with reading in a .txt from a HTTP:// address.

WHat is the correct code?

Thanks!
 
Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim w As New Net.WebClient()
        Dim sr As New IO.StreamReader(w.OpenRead("http://google.com"))
        Dim strSource As String = sr.ReadToEnd
        sr.DiscardBufferedData()
        sr.Close()
        w.Dispose()
        TextBox1.AppendText(strSource)
    End Sub
that should work :)
 
Back
Top