3

I am using the latest GeckoFX 18 (hindlemail's fork) and have tried hard to achieve this simple method : Handle file downloads.

I want to know if there is a file download happening in the GeckoWebBrowser. There is no file download event, and even worse : clicking a link that leads to a file download doesn't trigger /any/ event. It just doesn't do nothing. No download dialog, no save file dialog, no url, no nothing.

Is there a way I can handle file downloads ?

user1779764
  • 91
  • 2
  • 5
  • What about trying the [WebClient.Download()](http://msdn.microsoft.com/en-gb/library/ez801hhe.aspx) method? – Sam Apr 15 '13 at 15:32
  • I would really want that, but I cannot detect if there's a file download or not. There is no event for downloading files. Nothing to even show me the URL of the file. – user1779764 Apr 16 '13 at 19:11
  • What do you mean that you "can't detect" if there's a file download? If you know the URL of the file you want to download then just follow example i gave you in the previous link. – Sam Apr 16 '13 at 22:49

1 Answers1

2

By using hindlemail's fork of geckofx you will have to handle LauncherDialog.Download event. This event has several parameters like url, filename, etc.

LauncherDialog.Download += LauncherDialog_Download;
////
void LauncherDialog_Download(object sender, LauncherDialogEvent e)
{
    string filename = e.Filename; //do something with filename
    string url = e.Url; //use webclient to download file from this url
}

Even with this you will not be able to download files from secure sites like dropbox or facebook but it will download something, better than nothing. I don't know much about xul so I also has a hard time downloading files.

I tried this too:

void LauncherDialog_Download(object sender, LauncherDialogEvent e)
{
    WebBrowser ie = new WebBrowser();
    ie.Navigate(e.Url);
}

It will show Internet Explorer download file dialog if file can be downloaded that way. Probably cause of request headers or something. I also used Fiddler to find out what headers Firefox sends to server but I found nothing useful.

Visual Vincent
  • 18,045
  • 5
  • 28
  • 75
Zero Infinity
  • 918
  • 9
  • 17
  • Thanks for your time. I don't think this method would be useful since many more sites are implementing secure file downloads, and we have to be compatible with everything. – user1779764 Apr 19 '13 at 17:37
  • You welcome, I agree, AFAIK by default native downloader is not implemented at all. To do it you will need to edit source code of Geckofx. I got this code from guy that says it has already done it, but I cant get it to work. I tried to edit it and add to source but without luck. Looks like a nightmare to me :D [Geckofx downloader](http://pastebin.com/xfPLcfup) – Zero Infinity Apr 21 '13 at 11:04