Windows 10下的电脑Microsoft Edge将localstorage保存在什么地方?

问题描述 投票:0回答:2

我在哪里可以找到 Microsoft Edge 的 localstorage 文件夹?我正在寻找文件夹路径。

local-storage microsoft-edge
2个回答
4
投票

我测试了这个问题,并尝试在计算机上为 Edge 找到本地存储文件的位置。

根据我的搜索,这个文件是隐藏的,如果你打开显示隐藏文件的选项,那么这个文件也不会可见。

要查看此文件,您需要使用搜索选项在 Windows 资源管理器中查找该文件。

如果我从地址栏复制路径,那么它会在下面显示路径。

ms:displayname=Search%20Results%20in%20Default&crumb=System.Generic.String%3Alocalhost&crumb=location:C%3A%5CUsers%5Cpanchals%5CAppData%5CLocal%5CPackages%5CMicrosoft.MicrosoftEdge_8wekyb3d8bbwe%5CAC%5C#!001%5CMicrosoftEdge 5C用户%5C默认

如果我检查文件属性,它会显示下面的路径。

C:\Users\panchals\AppData\Local\Packages\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\AC#!001\MicrosoftEdge\User\Default\DOMStore\IS3DHS80

用户可以使用用户界面移动到“默认”文件夹,然后需要使用搜索选项来定位文件。

文件名将是本地主机[1]

要进行测试,用户可以参考下面的代码。

<!DOCTYPE html>
<html>
<head>
    <title>Simple Drawing App</title>
    <meta http-equiv="X-UA-Compatible" content="IE=10">
    <style>
        html {
            -ms-touch-action: none;
            text-align: center; /* Center all contents of the page. */
        }
    </style>
</head>
<body id="bodyElement">
    <!-- This ID is used in the following script block for feature detection. -->
    <h1>Simple Drawing App</h1>
    <h3>Example 2</h3>
    <canvas id="drawSurface" width="500" height="500" style="border:1px solid black;"></canvas> <!-- The canvas element can only be manipulated via JavaScript -->
    <div>
        <button id="erase">Erase</button>
        <button id="save">Save</button>
        <button id="load">Load</button>
    </div>
    <script>
        function requiredFeaturesAvailable() {
            return (
                !!window.addEventListener && // Use the double negative "!!" to force the object to a Boolean value.
                !!document.createElement('canvas').getContext &&
                !!window.localStorage
            );
        } // requiredFeaturesAvailable

        if (!requiredFeaturesAvailable()) {
            document.getElementById('bodyElement').innerHTML = "<h2>Required features are not supported by this browser.</h2><p>To use this application, upgrade your browser to the latest version.</p>";
        }
        else {
            window.addEventListener('load', init, false); // Safety first.

            function init() {
                var canvas = document.getElementById('drawSurface'); // A static variable, due to the fact that one or more local functions access it.
                var context = canvas.getContext('2d'); // A static variable, due to the fact that one or more local functions access it.

                context.fillStyle = "purple";

                if (window.navigator.msPointerEnabled) {
                    canvas.addEventListener('MSPointerMove', paintCanvas, false);
                }
                else {
                    canvas.addEventListener('mousemove', paintCanvas, false);
                }

                document.getElementById('erase').addEventListener('click', eraseCanvas, false);
                document.getElementById('save').addEventListener('click', saveCanvas, false);
                document.getElementById('load').addEventListener('click', loadCanvas, false);

                function paintCanvas(event) { // The "event" object contains the position of the pointer/mouse.
                    context.fillRect(event.offsetX, event.offsetY, 4, 4); // Draw a 4x4 rectangle at the given coordinates (relative to the canvas box). As of this writing, not all browsers support offsetX and offsetY.
                } // paintCanvas

                function saveCanvas() {
                    window.localStorage.canvasImage = canvas.toDataURL(); // Save the user's drawing to persistent local storage.
                } // saveCanvas

                function eraseCanvas() {
                    context.clearRect(0, 0, context.canvas.width, context.canvas.height);
                } // eraseCanvas

                function loadCanvas() {
                    var img = new Image(); // The canvas drawImage() method expects an image object.

                    img.src = window.localStorage.canvasImage; // Retrieve the last saved artistic achievement from persistent local storage.
                    img.onload = function () { // Only render the saved drawing when the image object has fully loaded the drawing into memory.
                        context.drawImage(img, 0, 0); // Draw the image starting at canvas coordinate (0, 0) - the upper left-hand corner of the canvas.
                    } // onload
                } // loadCanvas
            } // init
        } // else
    </script>
</body>
</html>

用户可以看到文件中的图像数据。

同时进行交叉检查,用户可以从开发人员工具输入本地存储中的数据,并尝试在文件中找到该数据。

输出:


1
投票

只是@Deepak-MSFT 的第一个答案的补充。 对于 Windows 应用商店 UAP,它将在 %localappdata%\Packages 中有一个独立的文件夹。 文件夹名称是 UAP appId。 如果我们在 UAP 中使用 localstorage,那么缓存文件将保存在: %localappdata%\Packages\UAPAPPID\AC。 在 AC 文件夹中搜索主机名,它会显示 localstorage 的存储 xml 文件。 文件名类似于: 主机名[1].xml

© www.soinside.com 2019 - 2024. All rights reserved.