0
var settings = new CefSettings();
        // Initialize cef with the provided settings
        settings.CachePath = "C:/Users/Anoni/Source/Repos/WindowsFormsApp1/bin/Debug/Cache";
        Cef.Initialize(settings);
        // Create a browser component
        chromeBrowser = new ChromiumWebBrowser("https://www.reddit.com/r/Turkishleft/");
        // Add it to the form and fill it to the form window.
        this.Controls.Add(chromeBrowser);
        chromeBrowser.Dock = DockStyle.Fill;
        string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
        settings.RemoteDebuggingPort = 8088;

These are my CefSharp settings. As you can see, CefSharp stores my cache in "C:/Users/Anoni/Source/Repos/WindowsFormsApp1/bin/Debug/Cache". But i want it to store cache wherever the application starts from. For example, if app start from "D:/", I want it to save cache in "D:/Cache". How can i make that happen?

  • `Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "Cache");` – Gusman Oct 17 '20 at 12:59
  • Does this answer your question? [Getting the application's directory from a WPF application](https://stackoverflow.com/questions/938421/getting-the-applications-directory-from-a-wpf-application) – Gusman Oct 17 '20 at 13:00
  • If you plan to deploy your app to users I'd suggest storing the cache in the users profile. CachePath needs to be user writable. See https://github.com/cefsharp/CefSharp.MinimalExample/blob/master/CefSharp.MinimalExample.WinForms/Program.cs#L35 for an example of what I'd usually recommend. – amaitland Oct 17 '20 at 23:18

1 Answers1

0

Found it. Line of code should be

settings.CachePath = Application.StartupPath + "/Cache";