在CefSharp中设置CachePath

时间:2015-06-05 14:25:52

标签: c# c++ visual-studio-2012 chromium-embedded cefsharp

我在visual studio 2012中设置了cefSharp,并在this的帮助下使用嵌入式URL构建。但我不知道如何正确设置cachePath。项目中大约有12个模块。我希望我的缓存文件可以保留,当下次用户加载浏览器时,它不会花费太多时间。

我真的很感谢你的帮助。

谢谢!

3 个答案:

答案 0 :(得分:1)

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);
}

答案 1 :(得分:0)

答案 2 :(得分:-1)

您可以使用此代码。

    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);
    }