.NET ez 2013-01-25
需先下載 DotNetZipLib
官方網站:http://dotnetzip.codeplex.com/
//壓縮檔案 using (ZipFile zip = new ZipFile("壓縮檔案路徑 c:\a.zip")) { //壓縮進度顯示 zip.SaveProgress += new EventHandler<SaveProgressEventArgs>((s, e) => { double Total = e.TotalBytesToTransfer, Now = e.BytesTransferred; Console.WriteLine("壓縮進度... ( " + String.Format("{0:0.00}", Math.Round(Now / Total * 100, 2)) + "% )"); }); zip.Comment = "壓縮檔註解"; zip.Password = "壓縮檔密碼"; zip.CompressionLevel = Ionic.Zlib.CompressionLevel.Level9; //壓縮等級 zip.MaxOutputSegmentSize = SegmentSize; //壓縮檔分割大小 最多只能分成100個 zip.AddFile("需壓縮的檔案路徑 c:\aaa.txt", String.Empty); zip.Save(); } //列出壓縮檔 using (ZipFile zip = new ZipFile("壓縮檔案路徑 c:\a.zip")) { foreach (ZipEntry detail in zip) { Console.WriteLine(detail.FileName); } }
標籤: .NET
本文章網址:
https://www.ez2o.com/Blog/Post/csharp-DotNetZipLib-Sample-Code
https://www.ez2o.com/Blog/Post/312
https://www.ez2o.com/Blog/Post/csharp-DotNetZipLib-Sample-Code
https://www.ez2o.com/Blog/Post/312