'Set UserData Folder Path for WebView2 in UWP (WinUI 2)

I would like to explicitly set the UserData Folder Path for an instance of a WebView2 in a WinRT Component built using C# and WinUI 2. All of the examples state that you should create an instance of CoreWebView2Environment and pass it to the WebView's EnsureCoreWebView2Async method call.

However, the WinUI 2 version of the EnsureCoreWebView2Async method call doesn't seem to accept any parameters and the WebView2's CoreWebView2's Environment property is read-only.

So....what do I do? Is there a workaround?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source