Cefsharp 75 为每个实例单独设置缓存目录
作者:互联网
设置全局缓存目录,很简单,代码如下:
CefSettings setting = new CefSettings(); setting.CachePath = AppDomain.CurrentDomain.BaseDirectory + "caches\\"; CefSharp.Cef.Initialize(setting);
这么一来,程序的每个ChromiumWebBrowser,都将往caches这个文件夹里读取/写入缓存信息
但是如果有多个ChromiumWebBrowser实例,并且想为每个实例设置不同的缓存目录呢?这边就需要用到RequestContext 属性
需要注意的是,如果设置了RequestContext .RequestContextSettings.CachePath 属性值,CefSettings.CachePath属性值需放空,否则会出现问题。
var subCacheFolder=""; ChromiumWebBrowser wb = new ChromiumWebBrowser("https://www.baidu.com/"); var requestContextSettings = new RequestContextSettings { CachePath = AppDomain.CurrentDomain.BaseDirectory+"caches\\"+subCacheFolder+"\\" }; wb.RequestContext = new RequestContext(requestContextSettings);
标签:Cefsharp,缓存,RequestContext,ChromiumWebBrowser,CachePath,75,setting,new 来源: https://www.cnblogs.com/gulangduxiao/p/12257884.html