如何在 Windows Mobile 中解压 .zip 文件?

发布于 2024-07-14 19:20:22 字数 85 浏览 5 评论 0原文

我需要以编程方式将 zip 存档解压到 Windows Mobile 上的文件夹中。 是否有一个易于使用的 API 可以直接使用,还是应该使用一些外部库?

I need to programaticaly unpack a zip archive to folder on Windows Mobile. Is there an easy to use API that I can use directly or should I go with some external library?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

半葬歌 2024-07-21 19:20:22

您需要一个外部库。 有一个 zlibce.dll,这是一个本机 DLL,如果您喜欢 C++,则可以使用它。

如果您喜欢 .NET,那么我可以推荐 DotNetZip,它在 .NETCF 2.0 上运行,是免费的、开放的来源,并且具有良好的文档,良好的性能。 在DotNetZip源代码发行版中,有一个CF-Unzipper项目可以查看和编译; 它演示了如何在设备上解压缩文件。 您可以通过以下链接查看设备应用的代码

这是代码中与 zip 相关的部分的片段。 它将解压缩到一个目录,该目录的名称取自 zip 文件(不带 .zip 扩展名)。

    private void UnzipSelectedFile()
    {
        string parent = System.IO.Path.GetDirectoryName(_selectedpath);
        string dir = System.IO.Path.Combine(parent,
            System.IO.Path.GetFileNameWithoutExtension(_selectedpath));
        try
        {
            using (var zip1 = new Ionic.Zip.ZipFile(_selectedpath))
            {
                foreach (var entry in zip1)
                {
                    entry.Extract(dir, true);
                }
            }

            // re-populate the treeview with the extracted files:
            AddChildren(tvFolders.SelectedNode.Parent);

        }
        catch (Exception ex)
        {
            MessageBox.Show("Exception! " + ex);
        }
    }

以下是该库该文档的在线版本的链接。

You need an external library. There is a zlibce.dll, a native DLL that you can use if C++ is your thang.

If .NET is your thing then I can recommend DotNetZip, which runs on the .NETCF 2.0, is free, open source, and has good doc, good performance. In the DotNetZip source distrib, there's a CF-Unzipper project that you can view and compile; it demonstrates how to unzip files on the device. Here's a link where you can view the code for the device app.

This is a snip of the zip-relevant parts of the code. It unzips to a directory that takes its name from the zip file (without the .zip extension).

    private void UnzipSelectedFile()
    {
        string parent = System.IO.Path.GetDirectoryName(_selectedpath);
        string dir = System.IO.Path.Combine(parent,
            System.IO.Path.GetFileNameWithoutExtension(_selectedpath));
        try
        {
            using (var zip1 = new Ionic.Zip.ZipFile(_selectedpath))
            {
                foreach (var entry in zip1)
                {
                    entry.Extract(dir, true);
                }
            }

            // re-populate the treeview with the extracted files:
            AddChildren(tvFolders.SelectedNode.Parent);

        }
        catch (Exception ex)
        {
            MessageBox.Show("Exception! " + ex);
        }
    }

Here's a link to an online version of the doc for the library.

踏月而来 2024-07-21 19:20:22

如果您使用 .Net Compact Framework,则可以使用 http://www.icsharpcode.net/OpenSource /SharpZipLib。 我相信它支持在CF上运行。

If you're using .Net Compact Framework you could go with http://www.icsharpcode.net/OpenSource/SharpZipLib. I believe it supports running on CF.

橘味果▽酱 2024-07-21 19:20:22

无论您使用哪种语言,都可以使用 Info-ZIP 作为外部可执行文件。

Regardless of what language you use you can use Info-ZIP as an external executable.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文