2009-03-06 71 views

回答

7

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

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

这是代码的压缩相关部分的片段。它将解压缩到一个目录,该目录的名称来自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

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

+0

按照http://www.info-zip.org/FAQ.html#WinCE - “我们目前没有计划做Zip的WinCE端口。我们希望最终做到这一点,但只有在时间允许的情况下,它已经被搁置超过八年(!)。不要屏住呼吸,呃?` – The1nk 2013-07-22 15:32:59