Search code examples
winapiwebview2

Using WebView2 with Microsoft Edge AppData


I am using WebView2 for Win32 applications, and I am looking to implement a functionality where WebView2 utilizes the AppData of Microsoft Edge.

Is there any way to accomplish this?

I have attempted to achieve this with the following code:

LPCWSTR dataFolder = L"C:\\Users\\Username\\AppData\\Local\\Microsoft\\Edge";
  
CreateCoreWebView2EnvironmentWithOptions(nullptr, dataFolder, nullptr,
    Callback<ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler>(
        [hWnd](HRESULT result, ICoreWebView2Environment* env) -> HRESULT {});

However, I have observed that CreateCoreWebView2EnvironmentWithOptions appends "EBWebView" at the end of the provided dataFolder location. Therefore, I am seeking to know if there is any alternative function or method available that can achieve this functionality.


Solution

  • I found the answer from various sources, including discussions and issues raised on the WebView2Feedback GitHub repository. Unfortunately, it seems that there is currently no direct way to make WebView2 utilize the AppData folder of Microsoft Edge.

    Here are the links to the relevant discussions and issues:

    1. WebView2Feedback Discussion: Accessing Edge's AppData
    2. WebView2Feedback Discussion: Using Edge's AppData for WebView2
    3. WebView2Feedback Issue: Access to Edge's AppData
    4. WebView2Feedback Issue: WebView2 and Edge's AppData

    These discussions and issues indicate that direct access to Edge's AppData folder from within WebView2 is not currently supported. Therefore, you may need to explore alternative approaches or reconsider your requirements for utilizing Edge's AppData within WebView2.