Search code examples
c#downloadcefsharpsavefiledialog

How to remove Save As dialog from download handler in CefSharp


I want to remove the SaveAs dialog from CefSharp and want the file to save directly to the specified location.Nothing seems to work out please help public void OnBeforeDownload(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) { OnBeforeDownloadFired?.Invoke(this, downloadItem);

            if (!callback.IsDisposed)
            {
                using (callback)
                {
                    callback.Continue("C:/Users/Wissensquelle/Downloads/bhavansh.txt", showDialog: false);
                }
            }
        }

Solution

  • I want to remove the SaveAs dialog from CefSharp and want the file to save directly to the specified location.

    This isn't possible to do (out of the box), if so, this would be a huge design flaw that would have great security issues.

    On another note, take a look at the DownloadHandler class, specifically the OnBeforeDownload method, you could however change it to your likings (more of a hassle):

     callback.Continue(downloadItem.SuggestedFileName, showDialog: true);
    

    To:

     callback.Continue(SOMEPATH, showDialog: false);