2011-03-09 99 views
0
Can any one have the idea how to zip folders (including sub files and folders like winrar doing) using C#...? 
+0

重複:[C#中的Zip文件夾](http://stackoverflow.com/questions/905654/zip-folder-in- C) – 2011-03-09 13:49:14

回答

1

快速谷歌,我發現在這之後#ziplib(SharpZipLib,以前NZipLib)是一個Zip,GZip,Tar和BZip2庫,完全用C#編寫的.NET平臺。)

2

這是一個相當不錯的通用.NET實用程序,用於處理與zip相關的操作和文件。 http://dotnetzip.codeplex.com/

用法的例子,從我剛纔提供的網站鏈接粘貼:SharpZipLib(從網站:

 

using (ZipFile zip = new ZipFile()) 
{ 
    // add this map file into the "images" directory in the zip archive 
    zip.AddFile("c:\\images\\personal\\7440-N49th.png", "images"); 
    // add the report into a different directory in the archive 
    zip.AddFile("c:\\Reports\\2008-Regional-Sales-Report.pdf", "files"); 
    zip.AddFile("ReadMe.txt"); 
    zip.Save("MyZipFile.zip"); 
}