Save file without saving file dialog box in C # webbrowser control

I am implementing a code to automatically download files from a client site without a manual step using C # code.

My requirement is to save files using C # code, skipping the path without saving the file dialog box.

This is the code to display the Save File dialog box when you click the Download button in the C # web browser control window.

foreach (HtmlElement row in webBrowser1.Document.Window.Frames["View_Frame"].Document.GetElementsByTagName("input")) { if (row.Name == "DOWNLOADALL") { row.InvokeMember("click"); tbState.Text = "4"; break; } } 
+4
source share
1 answer

You can use something like this so that no download dialog is displayed:

 WebClient client = new WebClient(); foreach (HtmlElement row in webBrowser1.Document.Window.Frames["View_Frame"].Document.GetElementsByTagName("input")) { if (row.Name == "DOWNLOADALL") { row.InvokeMember("click"); tbState.Text = "4"; client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"); client.DownloadFile(URL, path);//I don't know where is your URL and path! break; } } 

from here

+1
source

Source: https://habr.com/ru/post/1490444/


All Articles