|
Rank: Newbie Groups: Member
Joined: 9/23/2016 Posts: 5
|
I have a WebView that has a web page that lets you download multiple things at a time (you check a few items and click the download button). If I do not show the dialog, all the files download to the temporary folder. If I do show the dialog, only the first one downloads. I modified the save file dialog to only ask for a directory to save things to. My thought was that the first download would set the location, and the rest would not show the dialog. The first item asks for the directory, but next items have already passed the "BeforeDownload" event, so the save path has not been set. Only the first file downloads. If I always tell it to show the dialog, the dialog is only shown for the first file, and all others are ignored. Any thoughts on a way to ask for a folder to download multiple files to, and have all the files download there?
Code: C#
private string _savePath = "";
private void WebView_FileDialog(object sender, FileDialogEventArgs e)
{
if (_savePath == "")
{
if (e.Mode == FileDialogMode.Save)
{
var dialog = new Microsoft.Win32.SaveFileDialog();
dialog.InitialDirectory = e.DefaultFileName;
dialog.Title = "Select a Directory"; // instead of default "Save As"
dialog.Filter = "Directory|*.this.directory"; // Prevents displaying files
dialog.FileName = "select"; // Filename will then be "select.this.directory"
if (dialog.ShowDialog() == true)
{
string path = dialog.FileName;
// Remove fake filename from resulting path
path = path.Replace("\\select.this.directory", "");
path = path.Replace(".this.directory", "");
// If user has changed the filename, create the new directory
if (!System.IO.Directory.Exists(path))
{
System.IO.Directory.CreateDirectory(path);
}
// Our final value is in path
_savePath = path;
// go ahead and download the current file
e.Continue(System.IO.Path.Combine(path, System.IO.Path.GetFileName(e.DefaultFileName)));
e.Handled = true;
}
}
}
}
private void WebView_BeforeDownload(object sender, BeforeDownloadEventArgs e)
{
// https://www.essentialobjects.com/doc/eo.webbrowser.webview.beforedownload.aspx
if (_savePath != "")
{
e.FilePath = System.IO.Path.Combine(_savePath, System.IO.Path.GetFileName(e.FilePath));
e.ShowDialog = false;
}
}
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi,
I am not sure if there is a way to do this. Can you provide a test Url so that we can debug this through on our end? We should be able to tell you more once we debug it through our code.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 9/23/2016 Posts: 5
|
The website is served from a piece of hardware. I'll see if I can get a sample web site set up that simulates it.
|
|
Rank: Newbie Groups: Member
Joined: 7/14/2023 Posts: 1
|
Hello,
Is there any update on this problem? I believe we face the same issue. We call our partners application from our website. We open it in a separate WebView. While using our partner's app, the user may initiate the download of 3 files at once. If he/she does so only one "Save as" dialog is shown and consequentially only one file gets saved. The remaining two get cancelled (they trigger the DownloadCancelled event). The only way for this to "somehow work" is when we do something like: newWindowBrowser.WebView.FileDialog += (o, args) => { args.Handled = true; string filename = System.IO.Path.GetFileName(args.DefaultFileName); args.Continue(@"c:\temp\" + filename); } So basically we have to save to some predetermined location and not show any dialog at all. If there is any dialog shown (be it EO.Browser default dialog or our own) - the described problem occurs. Unfortunately I cannot give you access to our partner's app, but the behavior seems repeatable. To me it "looks like" this - as soon as the second Save As dialog is shown the previous one "automatically" gets cancelled.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi,
We have looked into this issue. It will be fixed in our next build due out next week. We will reply here again once the new build is available.
Thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi,
This is just to let you know that we have posted build 2023.2.65 that should fix this issue. In the new build if you have multiple downloads, the download dialogs will be displayed multiple times.
Please take a look and let us know if you still have any questions.
Thanks!
|
|