cefsharp/CefSharp

`IBeforeDownloadCallback`.Continue(path, showDialog:true) does not open correct path if full path with file name is used

m-kovac opened this issue · 2 comments

Is there an existing issue for this?

  • I have searched both open/closed issues, no issue already exists.

CefSharp Version

129.0.110

Operating System

Windows 11

Architecture

x64

.Net Version

.NET 4.8

Implementation

WinForms

Reproduction Steps

  1. Clone CefSharp.WinForms example
  2. Create custom IDownloadHandler and assign it to browser.DownloadHandler
  3. Implement the OnBeforeDownload method:
public bool OnBeforeDownload(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback)
{
    if (callback.IsDisposed)
    {
        return false;
    }

    using (callback)
    {
        var downloadedFilePath = Path.Combine("C:\\Users\\currentUser\\Downloads\\", downloadItem.SuggestedFileName);
        callback.Continue(downloadedFilePath, showDialog: true);
    }
    return true;
}
  1. Buld and start the project
  2. Go to https://codepen.io/chriddyp/pen/aVammp and download the example file

Expected behavior

The dialog should open in the "C:\Users\currentUser\Downloads" folder with pre-filled File name text field.

Actual behavior

The dialog is opened in the C:\Users\user folder with pre-filled File name text field. Only way to show the correct folder is to not specify the file name e.g.

var downloadedFilePath = "C:\\Users\\currentUser\\Downloads"; which will leave the File name text field and type of file empty.

Regression?

Same issue was spotted in v127.3.50 and v128.4.90

Known Workarounds

No response

Does this problem also occur in the CEF Sample Application

Not Tested

Other information

No response