简体   繁体   English

如何让 CefSharp 在 [App 的启动文件夹]/Cache 中存储缓存?

[英]How to make CefSharp store cache in [App's startup folder]/Cache?

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.这些是我的 CefSharp 设置。 As you can see, CefSharp stores my cache in "C:/Users/Anoni/Source/Repos/WindowsFormsApp1/bin/Debug/Cache".如您所见,CefSharp 将我的缓存存储在“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".例如,如果应用程序从“D:/”开始,我希望它将缓存保存在“D:/Cache”中。 How can i make that happen?我怎样才能做到这一点?

Found it.找到了。 Line of code should be代码行应该是

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM