在CefSharp中设置CachePath
本文关键字:CachePath 设置 CefSharp | 更新日期: 2023-09-27 17:53:32
我已经设置了CefSharp,并使用本教程的帮助构建了一个嵌入式URL。但是我不知道如何正确设置CachePath
。项目中大约有12个模块。我希望我的缓存文件被持久化,当下一次用户加载浏览器时,它不应该花太多时间。
public ChromiumWebBrowser browser;
private void Form1_Load(object sender, EventArgs e)
{
var newsettings = new BrowserSettings();
CefSettings Settings = new CefSettings();
Settings.CachePath = "test"; //always set the cachePath, else this wont work
//add an if statement to initialize the settings once. else the app is going to crash
if (CefSharp.Cef.IsInitialized == false)
CefSharp.Cef.Initialize(Settings);
var browser = new ChromiumWebBrowser(url) { Dock = DockStyle.Fill };
toolStripContainer1.ContentPanel.Controls.Add(browser);
}
设置CachePath
的示例如下:
https://github.com/cefsharp/CefSharp/blob/v39.0.2/CefSharp.Example/CefExample.cs L32
您可以使用此代码。
public ChromiumWebBrowser browser;
private void Form1_Load(object sender, EventArgs e)
{
var newsettings = new BrowserSettings();
CefSettings Settings = new CefSettings();
Settings.CachePath = "";
Cef.Initialize(Settings);
var browser = new ChromiumWebBrowser(TestUrl);
panel1.Controls.Add(browser);
}