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

时间:2009-03-06 07:07:03

标签: windows-mobile zip mobile-phones unzip

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

3 个答案:

答案 0 :(得分:7)

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

如果你的.NET是你的东西,那么我可以推荐在.NETCF 2.0上运行的DotNetZip是免费的,开源的,并且具有良好的文档,良好的性能。在DotNetZip源代码发布中,有一个可以查看和编译的CF-Unzipper项目;它演示了如何解压缩设备上的文件。这是一个链接,您可以view the code获取设备应用。

这是代码的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);
        }
    }

这是图书馆an online version of the doc的链接。

答案 1 :(得分:0)

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

答案 2 :(得分:-1)

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

相关问题