Skip to content

Commit 62e3a7a

Browse files
David ShoemakerDavid Shoemaker
authored andcommitted
API Review PR comment fixes
1 parent f04058f commit 62e3a7a

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

specs/UserDataFolder.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ stored in the WebView2 user data directory. This directory can be either
99
configured by you during creation of the webview2 control or calculated
1010
at runtime by the control if it wasn't set during creation.
1111

12-
The current WebView2 code is designed to use a the directory that the hosting
13-
application is running in as the default location. This has resulted in issues
12+
The current WebView2 code defaults the user data folder to the directory that
13+
contains the hosting application's executable. This has resulted in issues
1414
if running from a folder for which the WebView2 process doesn't have write access
1515
such as a Program Files folder. Work is in progress to change that default and
1616
will be forthcoming in later changes.
1717

18-
With the current guidance it is possible for you to have built
18+
With the current implementation it is possible for you to have built
1919
logic into your application with an assumption where the User Data is
2020
located. WebView2 changing that default can then result in a code error or
2121
possible crash.
@@ -41,12 +41,18 @@ always be an absolute path.
4141
```cpp
4242
HRESULT UserDataFolder()
4343
{
44-
// get the current user data folder from the webview environment object
45-
wil::unique_cotaskmem_string userDataFolder;
46-
m_webViewEnvironment->get_UserDataFolder(&userDataFolder);
44+
Microsoft::WRL::ComPtr<ICoreWebView2Environment6> WebViewEnvironment6;
45+
m_webViewEnvironment->QueryInterface(IID_PPV_ARGS(&WebViewEnvironment6));
4746

48-
// using the folder
49-
WriteAppLog(userDataFolder.get(), "Logging information");
47+
if (WebViewEnvironment6 != NULLPTR)
48+
{
49+
// get the current user data folder from the webview environment object
50+
wil::unique_cotaskmem_string userDataFolder;
51+
WebViewEnvironment6->get_UserDataFolder(&userDataFolder);
52+
53+
// using the folder
54+
WriteAppLog(userDataFolder.get(), "Logging information");
55+
}
5056
}```
5157

5258
```c#
@@ -57,7 +63,7 @@ HRESULT UserDataFolder()
5763
if (e.IsSuccess)
5864
{
5965
// Get the current user data folder
60-
String userDataFolder = webView.CoreWebView2.Environment->UserDataFolder();
66+
String userDataFolder = webView.CoreWebView2.Environment.UserDataFolder();
6167

6268
// using the folder
6369
WriteAppLog(userDataFolder, "Logging information");

0 commit comments

Comments
 (0)