CefSharp 自定义缓存目录

本文介绍如何使用CefSharp库自定义浏览器缓存目录,通过修改CefSettings设置本地缓存路径,实现对CefSharp浏览器组件缓存的定制化管理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

CefSharp 自定义缓存目录

 public void web_Auto_Init()
        {
            //实例一个Cef设置,设置其中的本地缓存路径
            CefSettings Settings = new CefSettings();
            Settings.CachePath = Directory.GetCurrentDirectory() + @"\Cache";
            //将Cef设置传进去,实例一个web_Auto
            Cef.Initialize(Settings);
            web_Auto = new ChromiumWebBrowser("www.qidian.com");
            this.Controls.Add(web_Auto);
            //web_Auto布局
            web_Auto.Dock = DockStyle.None;
            web_Auto.Location = new Point(0, 30);
            web_Auto.Size = new Size(this.Size.Width,this.Size.Height - 20);
            this.web_Auto.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
            | System.Windows.Forms.AnchorStyles.Left)
            | System.Windows.Forms.AnchorStyles.Right)));
            //web_Auto其他
            web_Auto.AddressChanged += new EventHandler<AddressChangedEventArgs>(web_Auto_AddressChanged);
            web_Auto.ConsoleMessage += new EventHandler<ConsoleMessageEventArgs>(web_Auto_ConsoleMessage);
            web_Auto.LoadingStateChanged += new EventHandler<LoadingStateChangedEventArgs>(web_Auto_LoadingStateChanged);
            web_Auto.FrameLoadEnd += new EventHandler<FrameLoadEndEventArgs>(web_Auto_FrameLoadEnd);
            //web_Auto.RequestHandler = new RequestHandler_new(web_Auto.RequestHandler);//获取任意 资源的关键处。
        }
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值