0

Hope you are doing good.

My requirement is to download some files from a site which requires login, password. I am able to navigate through all the way to the file generation page.(using .Net webBrowser control). I am stuck at file save dialog. I want to skip it but unable to do so as the there is no direct link to the file to be downloaded. A function is called and the file is created on the fly.

I am considering to use something else than webBrowser. Please guide me, if webkit also shows the same file dialog? Is there a respectively easier way to skip that using webKit?

I am using .Net 4.5 and windows 7 32 bit.

What i have already tried:

SendKeys.WaitSend("{Enter}")

Result: Enter is sent to the webbrowser control, not to the file download dialog. I have tried to get the process of the file dialog. But Process "WindowsFormsApplication.vshost"** doesn't have any child processes.

private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e)
WebClient client = new WebClient();
client.DownloadDataCompleted += new  DownloadDataCompletedEventHandler(client_DownloadDataCompleted);
client.DownloadDataAsync(e.Url);

Result: e.URL has no direct link. On clicking the file for download, a function is called at back-end. I have seen in Firefox the code inside that function, which is just this one line:

document.location.href = 'something.do?something='+variable1+'&something='+variable2+ '&something=' + variable3;

Investigating above, i am able to call that function directly by pasting the following line in browser.(in case my session has not expired):

https://something.com/downloadsomething.do?somevariable=45875&somenumber=54875125&somevariable=1Hg5422

and what i see next is a dialog box asking save/open/cancel.

Thank You, Regards

  • Webkit (atleast WebkitGTK) certainly supports not showing dialog - it all depnds upon how top level browser skin handles the events fired by core engine. I am using it to download the files without showing dialog. http://webkitgtk.org/reference/webkit2gtk/stable/WebKitDownload.html#webkit-download-set-destination. Sorry no idea about windows web browser control – user871199 May 19 '15 at 17:12
  • FYI: http://stackoverflow.com/a/19025793/1768303 – noseratio May 19 '15 at 21:54

1 Answers1

1

I have done it using pinvoke. By bringing the save dialog window to front and then sending keys to it.

IntPtr fileDownloadDialogPointer = FindWindow(null, "File Download");
SetForegroundWindow(fileDownloadDialogPointer);
SendKeys.SendWait("%s");

%s is for "Alt + S". After this, save as dialog will appear. Handling that too in the same way. Thank You ALL