Hi, @Theiss, Daniel. Welcome to Microsoft Q&A.
Purpose
WebView2 applications use the user data folder (UDF) to store browser data (such as cookies, permissions, and cached resources), which WebView2 could use to speed up the program.
When and how to create
The user data folder (UDF) is created for your WebView2 host app by the WebView2 control. The UDF is created in the default UDF location for the platform, or if your host app specifies a custom UDF location, the UDF is created in the custom UDF location. The UDF is created on startup of the WebView2 host app, if the UDF doesn't exist.
Can or need to clean this folder
If the folder currently takes up too much space, you could clear this folder. For example, clear the contents of a folder when it reaches a specified size.
private async Task ClearAutofillData()
{
double cleanSize = 10;
var userDataFolder = "The address of your UDF folder";
DirectoryInfo dirInfo = new DirectoryInfo(userDataFolder);
double folderSize = dirInfo.GetFiles("*", SearchOption.AllDirectories).Sum(file => file.Length) / (1024.0 * 1024.0);
if (folderSize >= cleanSize )
{
CoreWebView2Profile profile;
if (MyWebView2.CoreWebView2 != null)
{
profile = MyWebView2.CoreWebView2.Profile;
await profile.ClearBrowsingDataAsync();
}
}
}
For a more detailed description of this folder, you could refer to the official documentation:
2.https://learn.microsoft.com/en-us/microsoft-edge/webview2/concepts/clear-browsing-data?tabs=csharp
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.