Function ChangeFilename(ByVal Filext As String) As String Randomize() Dim ranNum As Integer = CInt(Int((900 - 100 + 1) * Rnd() + 100)) Dim FileName As String = Format(Now, "yyyyMMddHHmmss") & CStr(ranNum) & Filext Return FileName End Function Function UpRemoteFileToLocal(ByVal UpType As String, ByVal RemoteUrl As String, ByVal LocalFile As String) As Boolean On Error Resume Next Dim TmpResult As Boolean = False Select Case UpType Case "xmlhttp" 'With MSXML2 Dim myXmlHttp As New MSXML2.XMLHTTP40 myXmlHttp.open("GET", RemoteUrl, False) myXmlHttp.send("") Dim FS As FileStream = New FileStream(LocalFile, FileMode.CreateNew) Dim BW As BinaryWriter = New BinaryWriter(FS) BW.Write(myXmlHttp.responseBody) BW.Close() FS.Close() TmpResult = True Case "webclient" 'With System.Net NameSpace Dim myWebClient As New WebClient myWebClient.DownloadFile(RemoteUrl, LocalFile) TmpResult = True End Select Return TmpResult End Function
Randomize()
Dim ranNum As Integer = CInt(Int((900 - 100 + 1) * Rnd() + 100))
Dim FileName As String = Format(Now, "yyyyMMddHHmmss") & CStr(ranNum) & Filext
Return FileName
End Function
Function UpRemoteFileToLocal(ByVal UpType As String, ByVal RemoteUrl As String, ByVal LocalFile As String) As Boolean
On Error Resume Next
Dim TmpResult As Boolean = False
Select Case UpType
Case "xmlhttp"
'With MSXML2
Dim myXmlHttp As New MSXML2.XMLHTTP40
myXmlHttp.open("GET", RemoteUrl, False)
myXmlHttp.send("")
Dim FS As FileStream = New FileStream(LocalFile, FileMode.CreateNew)
Dim BW As BinaryWriter = New BinaryWriter(FS)
BW.Write(myXmlHttp.responseBody)
BW.Close()
FS.Close()
TmpResult = True
Case "webclient"
'With System.Net NameSpace
Dim myWebClient As New WebClient
myWebClient.DownloadFile(RemoteUrl, LocalFile)
TmpResult = True
End Select
Return TmpResult
End Function
我也知道, 用WebClient确实也没有任何一点可以让论坛认为我这个WebClient已经登录论坛了. 我想首先是应该让论坛知道, 这个WebClient已经登录论坛了吧. 没有头绪
http://web46624.s25.webcontrol.cn/webpage.txt
调用 WebPage(string _url, string _loginurl, string _post)第一参数,需要登入查看的页面URL,第二登入请求验证的URL ,第三登入传值过去的参数。