2012-04-10 27 views

回答

2

System.IO.Packaging是未與MonoTouch的支持(5.x)附帶的WindowsBase.dll一部分。

然而,它的類型,如ZipPackage不完全兼容正常壓縮文件,所以這可能不是理想的,如果你正在尋找處理.zip文件。在這種情況下,你最好使用@Jamie提到的庫。

如果你真的想要一些特定的類型System.IO.Packaging那麼你可以嘗試從單一的源代碼(開源),這是從gihub可用構建程序集。

+0

好感謝;) 我使用ICSharpCode SharpZipLib現在解決我的問題。 – Alex 2012-04-11 09:04:13

1

如果您想壓縮/解壓縮某些東西,您可能還想看看也可在MT中使用的System.IO.Compression.GZIPStream()。使用這樣的:

string sContent; 
string sDest = "zipped file with text content.zip"; 
using (FileStream oIn = File.OpenRead(sDest)) 
using (MemoryStream oOut = new MemoryStream()) 
using (GZipStream oZip = new GZipStream(oIn, CompressionMode.Decompress)) 
using (StreamReader oReader = new StreamReader(oOut)) 
{ 
    oZip.CopyTo(oOut); 
    oOut.Seek(0, SeekOrigin.Begin); 
    sContent = oReader.ReadToEnd(); 
} 
+0

我試過了,但我不能壓縮文件夾和一些更多的文件。但是,謝謝你;) – Alex 2012-04-11 09:02:47