Try
Dim Myrq As System.Net.HttpWebRequest = DirectCast(System.Net.HttpWebRequest.Create("http://www.foxtable.com/bbs/viewFile.asp?BoardID=2&ID=29891"), System.Net.HttpWebRequest)
Dim myCookieContainer As New System.Net.CookieContainer()
Dim WebBrowser1 As System.Windows.Forms.WebBrowser=Forms("窗口1").Controls("WebBrowser1").BaseControl
Dim cookieStr As String = WebBrowser1.Document.Cookie
Dim cookstr As String() = cookieStr.Split(";"c)
For Each str As String In cookstr
If str.Contains("SESSION") Then
Dim cookieNameValue As String() = str.Split("="c)
Dim ck As New System.Net.Cookie(cookieNameValue(0).Trim().ToString(), cookieNameValue(1).Trim().ToString())
ck.Domain = "www.foxtable.com"
'必须写对
myCookieContainer.Add(ck)
End If
Next
Myrq.CookieContainer = myCookieContainer
Dim myrp As System.Net.HttpWebResponse = DirectCast(Myrq.GetResponse(), System.Net.HttpWebResponse)
Dim totalBytes As Long = myrp.ContentLength
Dim st As System.IO.Stream = myrp.GetResponseStream()
Dim so As System.IO.Stream = New System.IO.FileStream("C:\test123.foxdb", System.IO.FileMode.Create)
Dim totalDownloadedByte As Long = 0
Dim by As Byte() = New Byte(1023) {}
Dim osize As Integer = st.Read(by, 0, CInt(by.Length))
While osize > 0
totalDownloadedByte = osize + totalDownloadedByte
Application.DoEvents()
so.Write(by, 0, osize)
osize = st.Read(by, 0, CInt(by.Length))
End While
so.Close()
st.Close()
MessageBox.Show("下载完毕!", "下载提示:", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1)
Catch ex As Exception
MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1)
End Try
配合WebBrowser获得SeSSION 可以满足你需求了.
[此贴子已经被作者于2013-5-14 15:40:38编辑过]