|
Rank: Advanced Member Groups: Member
Joined: 11/3/2015 Posts: 65
|
Hello,
I want to open a dialog before downloading a file which asks if the file should be downloaded or opened directly. Is that possible?
Best regards
Marius Kramer
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
You can try to handle ShouldForceDownload event and set e.ForceDownload to true in your event handler to force the browser to treat the page as a download. Note that this event is fired for both the top frame and iframes.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 11/3/2015 Posts: 65
|
Hi, thank you for your quick response. I don’t want to force the download, but I want to give the user the possibility to open it without downloading the file. regards
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
That's what force download is for. If a page can be directly opened by the browser, it will be displayed (opened) instead of being downloaded --- unless you force it as a download in this case. So if you force download, it will be downloaded, if you don't, it will be opened.
|
|
Rank: Advanced Member Groups: Member
Joined: 11/3/2015 Posts: 65
|
thank you, I will try it on monday
|
|
Rank: Advanced Member Groups: Member
Joined: 11/3/2015 Posts: 65
|
okay ... monday was a lie :D ...
now I've solved the problem ...
using something like this:
private void BeforeDownload(object sender, BeforeDownloadEventArgs e) { e.ShowDialog = false; }
private void DownloadCompleted(object sender, DownloadEventArgs e) { if (File.Exists(@e.Item.FullPath.ToString())) { System.Diagnostics.Process.Start(@e.Item.FullPath.ToString()); } else { MessageBox.Show("Unable to open file: " + @e.Item.FullPath.ToString()); } }
thanks :)
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Great. Glad to hear that you got it working!
|
|