Welcome Guest Search | Active Topics | Sign In | Register

EO Browser beforedownload event Options
bnymellon
Posted: Wednesday, March 10, 2021 12:48:43 PM
Rank: Advanced Member
Groups: Member

Joined: 3/10/2020
Posts: 59
Hi ,
We would like to save the file to our custom path instead of temp folder(Don't want to show the save file dialog prompt to user).
we tried to set the file path in beforedownload event but it overwrites file name.
Is there any property available for retrieving filename?


void WebView_BeforeDownload(object sender, BeforeDownloadEventArgs e)
{
e.ShowDialog = false;
e.FilePath = <documents folder>

}
eo_support
Posted: Thursday, March 11, 2021 5:04:38 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,066
Hi,

I am not sure if I understand your question correctly. If you wish to get the file name, you can always get it from e.FilePath before you overwrite it.

Thanks!
bnymellon
Posted: Tuesday, September 20, 2022 9:21:10 AM
Rank: Advanced Member
Groups: Member

Joined: 3/10/2020
Posts: 59
We are having an issue while downloading a PDF/ Excel from a web page in A WPF application using EO browser (v22.1.42.0)
We are handling BeforeDownload and DownloadCompleted events.
In beforedownload event, instead of using the default download path we are setting our custom path and save the file in custom folder location.
And in DownloadCompleted we will open the downloaded file using system.start process.

Everything looks good when we download the file for first time. But when we download the same file again its not at all downloading.

void WebView_BeforeDownload(object sender, BeforeDownloadEventArgs e)
{
BeforeDownloadStartEventArgs args = new BeforeDownloadStartEventArgs(e.FilePath, e.ShowDialog);
//getting the file path from e.filepath variable and change it to custom folder path location
e.FilePath = args.FilePath;
e.ShowDialog = false;
}

void WebView_DownloadCompleted(object sender, DownloadEventArgs e)
{
//will open the downloaded file from the location
Process.Start(e.FullPath);
}

Note:
If we show the download prompt, e.filepath path is setting the file name properly by appending incremental version to the downloaded file name in sequences.
Example file Name:
first download :SamplePDF.pdf
2nd download: SamplePDF(1).pdf
3rd download: SamplePDF(2).pdf
eo_support
Posted: Tuesday, September 20, 2022 1:59:40 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,066
Hi,

Do you mean that BeforeDownload/DownloadCompleted event doesn't fire at all? This is due to the fact that the file has already been cached so it simply load the file from the cache.

To avoid this you can try to do two things:

1. If you have control over the server, make sure it is set not cacheable for the downloaded files;
2. Otherwise you can use the default file path, however then use File.Move to move that file to your own path and then use Process.Start to load the file from that path;

Please let us know if this works for you.

Thanks!
bnymellon
Posted: Wednesday, September 21, 2022 7:24:12 AM
Rank: Advanced Member
Groups: Member

Joined: 3/10/2020
Posts: 59
Hi,
Thanks for responding.

In our case, we have set the e.ShowDialog = false in WebView_BeforeDownload event.

void WebView_BeforeDownload(object sender, BeforeDownloadEventArgs e)
{
BeforeDownloadStartEventArgs args = new BeforeDownloadStartEventArgs(e.FilePath, e.ShowDialog);
//getting the file path from e.filepath variable and change it to custom folder path location
e.FilePath = args.FilePath;
e.ShowDialog = false;
}

If we set the e.showDialog flag as true, then EO is opening the save dialog and its checks if file already available in the downloads path and set the file name with increment the file version. ( Eg: SamplePDF (1). )

EO is not able to increment the file version during download when we set the e.showDialog flag as false.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.