vb.net从web .txt文件中读取文本并在文本框中显示?

时间:2013-05-20 18:17:04

标签: .net vb.net

我正在尝试从互联网.txt文件中读取一些数字并在文本框中显示,但没有结果......

导入这些系统:

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

以下是阅读文件的代码:

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

1 个答案:

答案 0 :(得分:9)

请改为尝试:

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