Chelovek
Chelovek

Reputation: 159

vb.net read text from web .txt file and show it in textbox?

I am trying to read few number from internet .txt file and show it in text box, but without result...

These systems are imported:

Imports System.IO
Imports System.Text
Imports System.Net

Here is the code of reading file:

Dim address As String = "http://www.url.com/text.txt"
Dim client As WebClient = New WebClient()
Dim reply As String = client.DownloadString(address)
TextBox2.Text = reply

Upvotes: 6

Views: 29518

Answers (1)

maxedev
maxedev

Reputation: 941

Try this instead:

Dim address As String = "http://www.stackoverflow.com"
Dim client As WebClient = New WebClient()
Dim reader As StreamReader = New StreamReader(client.OpenRead(address))
Textbox2.Text = reader.ReadToEnd

Upvotes: 12

Related Questions