Set UserDataFolder in C# WPF #5372
Unanswered
JRWest2000
asked this question in
Q&A
Replies: 1 comment
-
|
You've got to get it beforehand. %appdata% will not be expanded if passed as a variable: string userDataFolder = System.IO.Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
"YourAppName",
"WebView2Data"
);
// Ensure the directory exists
Directory.CreateDirectory(userDataFolder);
// Create the environment with the resolved path
var env = await CoreWebView2Environment.CreateAsync(
browserExecutableFolder: null,
userDataFolder: userDataFolder,
options: null
); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have been trying for days to set the user data folder for a webView2 control in a C# WPF desktop application I can find no way to set it to the users appdata directory, when I don’t know the user name ahead of time. Every attempt to set the environmental variable gives an already exist error.
Beta Was this translation helpful? Give feedback.
All reactions