我试图从互联网.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
解决方法
试试这个:
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