我正在尝试从互联网.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
答案 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