vb.net 从 web .txt 文件中读取文本并将其显示在文本框中?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16655735/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 12:15:53 来源:igfitidea点击:
vb.net read text from web .txt file and show it in textbox?
提问by Chelovek
I am trying to read few number from internet .txt file and show it in text box, but without result...
我试图从互联网 .txt 文件中读取一些数字并将其显示在文本框中,但没有结果......
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
回答by maxedev
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

