求助如何读取服务器上的文本文件
最近申请了个虚拟主机,请问如何不用下载后再读取,而是直接读取,而且读出来没有乱码.[ 本帖最后由 mp654k 于 2012-5-15 16:07 编辑 ]
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