http download & cookies

  • Thread starter Thread starter Nikolay Petrov
  • Start date Start date
N

Nikolay Petrov

I have this problem.
I have to download a document from a web site in specified intervals of time
and save it to hdd.
The problem is that before I get to document I have to login to site by a
web form authentication.
The login form have an option to remember by login by storing a cookie on my
PC.
The question is may I somehow use this saved cookie in my VB app to get the
document, or is there a way to fill the login details in the login form?

TIA
 
Hi,

Here is an example on how to download a file from a windows form.
You will need to add a webrequest.credentials to automatically logon to the
site.

http://msdn.microsoft.com/library/d...fsystemnetwebrequestclasscredentialstopic.asp


Dim request As WebRequest

Dim response As WebResponse

Dim reader As Stream

Dim writer As Stream

Dim data(1023) As Byte

Dim count As Integer

Dim total As Integer

Me.Show()

Me.Text = "Downloading file ....."

Application.DoEvents()

request =
WebRequest.Create("http://www.onteorasoftware.com/downloads/multigrids.zip")

response = request.GetResponse()

reader = response.GetResponseStream()

ProgressBar1.Maximum = CInt(response.ContentLength)

ProgressBar1.Value = 0

total = 0

writer = File.Create("mylocaldata.zip")

While True

count = reader.Read(data, 0, 1024)

If count <= 0 Then

Exit While

End If

writer.Write(data, 0, count)

total += 1024

If total < ProgressBar1.Maximum Then ProgressBar1.Value = total

Application.DoEvents()

End While

reader.Close()

writer.Close()



Ken

--------------------------

I have this problem.
I have to download a document from a web site in specified intervals of time
and save it to hdd.
The problem is that before I get to document I have to login to site by a
web form authentication.
The login form have an option to remember by login by storing a cookie on my
PC.
The question is may I somehow use this saved cookie in my VB app to get the
document, or is there a way to fill the login details in the login form?

TIA
 
I can't use webrequest.credentials because the login process is made as a
login form, can I?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top