| | |
On-the-fly automated file download
Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Jun 2009
Posts: 7
Reputation:
Solved Threads: 0
My problem is this: I am trying to automate the download, parsing, and insertion of an excel file into a database. I have the parser and inserter done, but I can't seem to find a way to download the files automatically.
The core of the issue is that the website seems to generate the file names on the fly. So far, we have been trying to use a WebBrowser control to access the website, log in, and run the website's download script, at which point a 'save file' dialog box pops up with the file we want to save. This, however, requires human input which is the exact opposite of what automation is all about.
So, my question is this: is there a better way to do this? And if not, is there a way to access that dialog box and get the file from it?
The core of the issue is that the website seems to generate the file names on the fly. So far, we have been trying to use a WebBrowser control to access the website, log in, and run the website's download script, at which point a 'save file' dialog box pops up with the file we want to save. This, however, requires human input which is the exact opposite of what automation is all about.
So, my question is this: is there a better way to do this? And if not, is there a way to access that dialog box and get the file from it?
Last edited by adamf07; Jun 4th, 2009 at 12:16 pm.
You should override the Navigating event of the browser control. You're going to have to figure out when the URL is the download url (the file name might change, but it might be in a certain path or something), and cancel the navigation, then download the url with the WebClient class.
C# Syntax (Toggle Plain Text)
private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e) { //e.Url is the URL of the request //e.Cancel = true; will cancel the request in the web browser so you can handle it on your own }
Last edited by Tekmaven; Jun 5th, 2009 at 1:10 am.
-Ryan Hoffman
.NET Specialist / Webmaster, Extended64.com.
Please do not email or PM me with support questions. Please direct them to the forums instead.
.NET Specialist / Webmaster, Extended64.com.
Please do not email or PM me with support questions. Please direct them to the forums instead.
So what exactly initiates the download? It comes from javascript? You might have to just parse the javascript. Sendkeys would be a cop out
-Ryan Hoffman
.NET Specialist / Webmaster, Extended64.com.
Please do not email or PM me with support questions. Please direct them to the forums instead.
.NET Specialist / Webmaster, Extended64.com.
Please do not email or PM me with support questions. Please direct them to the forums instead.
•
•
Join Date: Jun 2009
Posts: 7
Reputation:
Solved Threads: 0
•
•
•
•
So what exactly initiates the download? It comes from javascript? You might have to just parse the javascript. Sendkeys would be a cop out
Thanks for the help.
![]() |
Similar Threads
- File Download Dialog Box(ASP) (ASP)
- file download problem (Perl)
- File Download Dialog Box(ASP) (ASP)
- File Download dialog Box Not appearing (Windows NT / 2000 / XP)
- IE; Getting file download box when attempting to access a particular web page (Web Browsers)
- File Download - Security Warning - Win XP (ASP.NET)
Other Threads in the C# Forum
- Previous Thread: Recognize and use spaces in multiline textbox
- Next Thread: Decompress large file
| Thread Tools | Search this Thread |
.net access algorithm api array asp.net barchart bitmap box broadcast c# check checkbox client combobox control conversion csharp custom database databaseconnection datagrid datagridview dataset datetime dbconnection degrees design development draganddrop drawing encryption enum eventhandlers excel file firefox form format forms function gdi+ grantorrevokepermissionthroughc#.net image index input install java label libraries list listbox loop mandelbrot marshalbyrefobject math mouseclick movingimage mysql mysql.data.client operator path photoshop php picturebox pixelinversion platform post programming radians regex remoting resourcefile richtextbox server sleep socket sql statistics stream string study system.servicemodel table tcpclientchannel text textbox thread time timer update usercontrol validation visualstudio webbrowser windows winforms wpf wpfc# xml





