Is there a Registry value to get Edge browser's user data location?

1.2k views Asked by At

My Application uses Edge browser to launch webpages in app. I am following WebView2 API.

I want to pass "C:\Users\<user>\AppData\Local\Microsoft\Edge" as "userDataFolder" argument to CreateCoreWebView2EnvironmentWithOptions(), as this location is where the browser data is stored.

I don't want my app data in my application folder.

How can I get the Edge browser's user data location from inside my application? Is there a Registry value I can read for this?

1

There are 1 answers

0
David Risney On

You should not use the Edge browser's user data folder as the user data folder for an instance of WebView2.

End users will not expect other apps to be changing state in their browser. Additionally due to the architecture of chromium, sharing a user data folder also means sharing a browser process and related processes. The Edge browser is not designed to support this and assumes it can control the lifetime of its processes. The WebView2 may have its processes closed seemingly for no reason. Similarly for the end user using the browser.

Additionally, if you try to use a folder shared by more than one app with no coordination between them, there's no separation of your data from other app's data so no way to cleanup your data when your app is uninstalled.

In part to help prevent this from happening, the path specified in the user data folder parameter is not the direct path used to store data by the WebView2. The WebView2 uses a folder under this so that you cannot pick the browser's user data folder.