Karthi Keyan

Karthi Keyan

  • 926
  • 755
  • 229.6k

Donwload file from Website.

May 19 2017 1:29 AM
Hi All,
 
   I use the below code to download the file from one website. but it's not working. it's not downloading the file. 
 
   In my code, the invoke is a HtmlElement that have the href attribute. the attribute value is URL link. 
 
foreach (HtmlElement invoke in aa)
{
   if(invoke.InnerText == "epub")
   {   
      string dwnlodpath = invoke.GetAttribute("href");
      
      WebClient client = new WebClient();
      DownloadProgressChangedEventHandler(ProgressChanged);
      client.DownloadFileAsync(new Uri(dwnlodpath), @"D:\");
   }
 
and also i tried without WebClient by invoke the link. Like follow,
 
 
foreach (HtmlElement invoke in aa)
{
   if(invoke.InnerText == "epub")
   {
       invoke.InvokeMember("click");
   }
 
but it was asking open or save option. i dont need that option. it automatically save the file in specified path. and how can i use the crome browser for this downloading. help me to solve this issue.
 
Thankz in advance. 

Answers (1)