private void tsbtnUserConfig_Click(object sender, EventArgs e) { var result = new FormUserConfig().ShowDialog(); if (result == DialogResult.Abort) { // How can I stop WebView2 from occupying the files? // I cannot delete the entire DataDirectory mainWebBrowser.Dispose(); if (File.Exists(PreferenceManager.PreferencePath)) { File.Delete(PreferenceManager.PreferencePath); } if (!PlatformFunction.IsMono) { PlatformFunction.UnsetWebBrowserFeatures(); } PreferenceManager.Current = null; Application.Exit(); } if (PreferenceManager.Current != null) { updateTitleAndSaveBtn(); } }
private FormGuide(string url, Form owner) { InitializeComponent(); Text = Program.BrandName + " Guide"; Size = new Size(owner.Size.Width * 3 / 4, owner.Size.Height * 3 / 4); VisibleChanged += (sender, args) => this.MoveToCenter(owner); browser = new ChromiumWebBrowser(url) { KeyboardHandler = new CustomKeyboardHandler(null) }; browser.BrowserSettings.BackgroundColor = (uint)BackColor.ToArgb(); var browserComponent = new CefBrowserComponent(browser); var browserImpl = new BaseBrowser(browserComponent); BrowserUtils.SetupDockOnLoad(browserComponent, browser); Controls.Add(browser); Disposed += (sender, args) => { browserImpl.Dispose(); browser.Dispose(); }; }