如何在[应用程序的启动文件夹]/Cache 中制作 CefSharp 存储缓存?
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;
这些是我的 CefSharp 设置。如您所见,CefSharp 将我的缓存存储在“C:/Users/Anoni/Source/Repos/WindowsFormsApp1/bin/Debug/Cache”中。但我希望它在应用程序启动的任何地方存储缓存。例如,如果应用程序从“D:/”开始,我希望它在“D:/Cache”中保存缓存。我怎样才能做到这一点?
找到了。代码行应该是
settings.CachePath = Application.StartupPath + "/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;
这些是我的 CefSharp 设置。如您所见,CefSharp 将我的缓存存储在“C:/Users/Anoni/Source/Repos/WindowsFormsApp1/bin/Debug/Cache”中。但我希望它在应用程序启动的任何地方存储缓存。例如,如果应用程序从“D:/”开始,我希望它在“D:/Cache”中保存缓存。我怎样才能做到这一点?
找到了。代码行应该是
settings.CachePath = Application.StartupPath + "/Cache";