个人资料

跳过导航链接首页 > 博客列表 > 博客正文

UWP/WinUI将压缩包解压到本地文件夹

:

示例代码:

    public static async Task UnzipPythonToLocalFolderAsync()
    {
        var localFolder = ApplicationData.Current.LocalFolder;
        var pythonLocalPath = Path.Combine(localFolder.Path, "python");

        // 检查是否已解压过
        if (Directory.Exists(pythonLocalPath) && Directory.GetFiles(pythonLocalPath).Length > 0)
            return;

        // 获取包内 python.zip 的物理路径
        var installFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
        var pythonZipFile = await installFolder.GetFileAsync("python.zip");
        var pythonZipPath = pythonZipFile.Path;

        // 解压到 LocalFolder/python
        ZipFile.ExtractToDirectory(pythonZipPath, pythonLocalPath, overwriteFiles: true);
    }

songshizhao
最初发表2025/9/25 2:57:36 最近更新2025/9/25 2:57:36 118
为此篇作品打分
10