2009-03-06 69 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