我正在使用Visual Basic 2010 Express并找到了一种读取文件的方法:
Dim byter = My.Computer.FileSystem.ReadAllBytes(“C:/ Documents and Settings / textfile.txt”)
如果我想阅读网站内容,我可以做类似的事情吗?
答案 0 :(得分:0)
尝试类似:
Dim uri as New Uri("http://thewebsite")
Dim request as HttpWebRequest = HttpWebRequest.Create(uri)
request.Method = WebRequestMethods.Http.Get
Dim response As HttpWebResponse = request.GetResponse()
Dim reader As New StreamReader(response.GetResponseStream())
Dim webpageContents As String = reader.ReadToEnd()
response.Close()