我如何使用 Visual Basic 从主机服务器读取文本文件?
我们的链接:yourname.com/file.txt
使用HttpWebRequest
类:
Dim request = DirectCast(WebRequest.Create("http://wordpress.org/extend/plugins/about/readme.txt"), HttpWebRequest)
Dim response = DirectCast(request.GetResponse(), HttpWebResponse)
Using sr As New StreamReader(response.GetResponseStream())
Do While sr.Peek() >= 0
Console.WriteLine(sr.ReadLine())
Loop
End Using