VB求助如何读取服务器上的文本文件?
以下是在.net论坛找到的代码,看不懂,不知道怎么用,VB怎么弄Imports
Imports
Public Class Form1
Private Function GetUrlFileText(ByVal FileUrl As String) As String
'FileUrl 是你要读取的远程文件的完整路径,如: https://bbs.bccn.net/Temp/Text.txt
Dim MyUrl As New Uri(FileUrl)
Dim MyQuest As WebRequest = WebRequest.Create(MyUrl)
Dim resp As WebResponse = MyQuest.GetResponse()
Dim MyStr As Stream = resp.GetResponseStream()
Dim read As StreamReader = New StreamReader(MyStr, System.Text.Encoding.Default)
Dim tmpStr As String = read.ReadToEnd
read.Close()
Return tmpStr
End Function
End Class
_______________________________