I am implementing code to automatic download files from client site without manual step using C# code.
My requirement is to save the files through C# code by passing path without save file dialog.
This is code to show the Save file dialog when click on Download button in C# window WebBrowser control .
foreach (HtmlElement row in webBrowser1.Document.Window.Frames["View_Frame"].Document.GetElementsByTagName("input"))
{
if (row.Name == "DOWNLOADALL")
{
row.InvokeMember("click");
tbState.Text = "4";
break;
}
}
You can use something like this that would not show any dialog for download:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With