CefSharp清除缓存路径崩溃应用程序

时间:2019-03-19 07:49:32

标签: c# winforms cefsharp

我正在使用以下代码在Winform应用程序中创建CefSharp浏览器:

ChromiumWebBrowser browser = new ChromiumWebBrowser("");

RequestContextSettings requestContextSettings = new RequestContextSettings { CachePath = "mycachepath" };
browser.RequestContext = new RequestContext(requestContextSettings, new CustomRequestContextHandler());

这是我用来清除此浏览器的代码:

if (instaBrowser != null)
{
    if (browserPanel.Controls.Contains(browser))
        browserPanel.Controls.Remove(browser);

    if (browser.RequestContext != null)
        browser.RequestContext.Dispose();

    if (!browser.IsDisposed)
        browser.Dispose();

    browser = null;
}

尽管我清除了该浏览器,但是当我尝试在几秒钟后清除缓存路径时却收到错误消息:

The process cannot access the file 'Visited Links' because it is being used by another process.

删除缓存路径功能:

String cachePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Users\" + userName;
if (Directory.Exists(cachePath))
{
    Directory.Delete(cachePath, true);
}

有什么问题吗?

0 个答案:

没有答案