Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I change default EBWebView folder path. #295

Closed
Birol2010 opened this issue Jun 22, 2020 · 5 comments
Closed

How can I change default EBWebView folder path. #295

Birol2010 opened this issue Jun 22, 2020 · 5 comments
Assignees

Comments

@Birol2010
Copy link

When we use WebView2 in Windows form application and first time run it, It could create exe-name.webview2/EBWebView folder in the executable file path. How can I set the new location of it before first running.

@david-risney david-risney self-assigned this Jun 22, 2020
@david-risney
Copy link
Contributor

david-risney commented Jun 22, 2020

You can set the user data folder in the CoreWebView2Environment.CreateAsync method. The second parameter is the user data folder, and the other two parameters may be null to use their default values.

You can then have the WinForms WebView2 use your CoreWebView2Environment to create its CoreWebView2 by calling the WebView2.EnsureCoreWebView2Async method.

However, you must call EnsureCoreWebView2Async before you set the WebView2.Source property as setting that property implicitly causes initialization to begin with a default CoreWebView2Environment. This is likely how you were seeing the default user data folder getting created.

You can read more about WinForms WebView2 control initialization in the WebView2.EnsureCoreWebView2Async documentation.

And for reference, here are some more notes on the user data folder.

@Birol2010
Copy link
Author

Birol2010 commented Jun 24, 2020

Can you make a property for this in the WebView2 control? It would be better to set the path after the InitializeComponent method.
Like this
InitializeComponent();
webView21.UserDataFolder=Path.GetTempPath();

@david-risney
Copy link
Contributor

The WinForms & WPF WebView2 controls have a CreationProperties property you can also use to more easily set the UserDataFolder via the designer or xaml.

@hugoam
Copy link

hugoam commented Feb 23, 2021

Why not have a more sensible default though, like for example, the application data folder where .NET automatically stores other stuff (like the application settings) ?

@champnic
Copy link
Member

champnic commented Mar 6, 2021

@hugoam We are currently investigating to see if we can pick a different default that will automatically work in more scenarios. I believe we are tracking this in #297.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants