Catch the download dialog from webbrowser control

  • Thread starter Thread starter Andre Rode
  • Start date Start date
A

Andre Rode

Hi,
I hope you can help me. I'm using VB2008 Express on a .NET 2.0 tool.

I need to get a csv file from a website. The site is coded in
JavaServerFaces if this means something.

For this the following procedure is needed:

1) Login
2) Navigate to export site
3) download the export.

Number 1+2 works really fine now.
The problem is, I know the URL of the csv file, but this is only a csv file
when there's a special header. I tried to reconstruct the header and write
it to a HttpWebRequest.GetRequestStream. But this fires me back to the HTML
code of the login site, something's missing, but I don't know what.

My new idea is to try to download like this:

Me.WebBrowser1.Document.GetElementById
("orderTableSorted:exportCSV").InvokeMember("Click")

This works, and I get the Open / Save / Cancel dialog of the IE.
But my program is meant to do his work silently.
How can I catch the event?

DocumentCompleted is too late, FileDownload doesn't react.

Hope you can help me,
greetings from Germany
André
 
Hi,
I hope you can help me. I'm using VB2008 Express on a .NET 2.0 tool.

I need to get a csv file from a website. The site is coded in
JavaServerFaces if this means something.

For this the following procedure is needed:

1) Login
2) Navigate to export site
3) download the export.

Number 1+2 works really fine now.
The problem is, I know the URL of the csv file, but this is only a csv file
when there's a special header. I tried to reconstruct the header and write
it to a HttpWebRequest.GetRequestStream. But this fires me back to the HTML
code of the login site, something's missing, but I don't know what.

My new idea is to try to download like this:

Me.WebBrowser1.Document.GetElementById
("orderTableSorted:exportCSV").InvokeMember("Click")

This works, and I get the Open / Save / Cancel dialog of the IE.
But my program is meant to do his work silently.
How can I catch the event?

DocumentCompleted is too late, FileDownload doesn't react.

Hope you can help me,
greetings from Germany
André

Do you just want to download this csv file or whatsoever?

Do this simply with:
My.Computer.Network.DownloadFile class

Or if you had to still struggle with webbrowser control, you can tell
the control that you want to download file that is not actuall an web-
based file by doing the following:

Private Sub WebBrowser_Navigating(ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.WebBrowserNavigatingEventArgs)
_
Handles WebBrowser.Navigating
If Not e.Url.IsFile Then
' Download it
my.computer.network.downloadfile(...' arguments here...)
End If
End Sub


Hope this helps.
 
Back
Top