1

I want to develop Internet explorer add-on. I need to detect when user download file, But I didn't find a relevant event for that. in this link there is a list of events, but there is no event for user that begin to download file

code example (took if from the link):

using mshtml;
using SHDocVw;
class EventHandlers
{
    public void OnBeforeNavigate2(object sender, ref object URL, 
                                  ref object Flags, ref object Target, 
                                  ref object PostData, ref object Headers, 
                                  ref bool Cancel) 
    {
        Console.WriteLine("BeforeNavigate2 fired!");
    }
}

class Program
{
    static void Main(string[] args)
    {
        EventHandlers e = new EventHandlers();
        SHDocVw.InternetExplorer IE = new SHDocVw.InternetExplorer();
        object Empty = 0;
        object URL = "http://www.live.com";

        // override BeforeNavigate2 event
        IE.BeforeNavigate2 += new
             SHDocVw.DWebBrowserEvents2_BeforeNavigate2EventHandler(
                     e.OnBeforeNavigate2);

        IE.Visible = true;
        IE.Navigate2(ref URL, ref Empty, ref Empty, ref Empty, ref Empty);

        System.Threading.Thread.Sleep(5000);

        IE.Quit();
    }
}
spez
  • 409
  • 8
  • 21
  • noboby knows?.. – spez Feb 25 '20 at 04:58
  • From your code, it seems that you want to achieve the IE automation, when and how user triggers the download event? whether the navigated website is developed by yourself, if it is developed by yourself, you could track the download button. And, you could also try to [use javascript to detect the file download](https://stackoverflow.com/questions/1106377/detect-when-browser-receives-file-download). Besides, you might consider using [the DownloadBegin event](https://learn.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa768283(v=vs.85)). – Zhi Lv Feb 25 '20 at 07:10
  • @ZhiLv-MSFT No, the navigated website isn't developed by myself, it can be any website. the [DownloadBegin](https://learn.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa768283(v=vs.85)) event: "Fires when a navigation operation begins." therefore this event doesn't help – spez Feb 25 '20 at 07:15
  • If that is the case, I think there is no event to check whether the file is downloaded. – Zhi Lv Feb 26 '20 at 09:18

0 Answers0