Site Meter & 線上人數

tracker

部落格觀察


我的噗浪

Google Latitude

微軟認證



聯絡我 - MSN & Skype & Email



最新回應

DotNetZip 1.3 Release (2008/2/5)

2008/2/10 23:41| 閱讀數 : 2268 | 我要推薦 | 4 Comments | 文章分類: C# Library 訂閱

DotNet Zip Library 是我覺得 SharpZip 之外另一個比較好用的壓縮與解壓縮的類別庫。

Project Description
The Microsoft .NET Framework {v2.0 v3.0 v3.5} includes base class libraries supporting compression within streams - both the Deflate and Gzip formats are supported. But the System.IO.Compression namespace provides streaming compression only - useful for communicating between cooperating parties but not directly useful for creating compressed archives, like .zip files. The built-in compression library does not know how to format zip archive headers and so on.

To address this, this simple class library augments the System.IO.Compression.DeflateStream class, to provide handling for Zip files. Using this library, you can write .NET applications that read and write zip-format files.

Frequently Asked Questions


How does this Zip Library work?
There's a single DLL, a single assembly, fully managed code, written in C#, that provides support for reading and writing Zip archive files.

What do I need to "do" zip files from within my application?
To use the zip capability in your applications, you need to be using the .NET Framework 2.0 or later. You can use the Zip library from any application, whether a console application, a Windows-Forms application, a server-based application, or something else.

How big is the library?
The zip DLL is about 36k in size. There is no other pre-requisite.

Limitations
---------------------------------

There are numerous limitations to this library:

it does NOT support encryption, file comments, or double-byte chars in filenames.

it does NOT support file lengths greater than 0xffffffff.

it does NOT support "multi-disk archives."

it does NOT do varying compression levels.

it can actually expand the size of previously compressed data, such as JPG files.

there is no GUI tool

簡單範例:

   1:  /* 將 C:\TMP\TMP2\01.jpg 檔案壓縮至 test01.zip 檔案中的 TMP\TMP2\01.jpg  
   2:   * 將 D:\02.jpg 檔案壓縮至 test01.zip 檔案中的 02.jpg  
   3:   * 將 C:\TMP\03.jpg 檔案壓縮至 test01.zip 檔案中的 TMP\03.jpg
   4:   */
   5:  using (ZipFile zip = new ZipFile(@"C:\test01.zip"))
   6:  {
   7:      zip.AddFile(@"C:\TMP\TMP2\01.jpg");
   8:      zip.AddFile(@"D:\02.jpg");
   9:      zip.AddFile(@"C:\TMP\03.jpg");
  10:      zip.Save();
  11:  }
  12:   
  13:  // 將 TMP2 目錄壓縮至 test02.zip 檔案中的 TMP\TMP2 目錄
  14:  using (ZipFile zip = new ZipFile(@"C:\test02.zip"))
  15:  {
  16:      zip.AddDirectory(@"C:\TMP\TMP2");
  17:      zip.Save();
  18:  }
  19:   
  20:  /* 將 TMP2 目錄壓縮至 test03.zip 檔案中的 TTT 目錄 
  21:   * 將 C:\TMP\03.jpg 檔案壓縮至 test03.zip 檔案中的 TTT\03.jpg 
  22:   */
  23:  using (ZipFile zip = new ZipFile(@"C:\test03.zip"))
  24:  {
  25:      zip.AddFile(@"C:\TMP\03.jpg", "TTT");
  26:      zip.AddItem(@"C:\TMP\TMP2", "TTT");
  27:      zip.Save();
  28:  }
  29:   
  30:  // 將 C:\test03.zip 檔案解壓縮至 C:\
  31:  using (ZipFile zip = new ZipFile(@"C:\test03.zip"))
  32:  {
  33:      zip.ExtractAll(@"C:\");
  34:  }

DotBlogs Tags: C# chhuang Library


關連文章

回應

  • bruce 2008/7/16 下午 06:31 回覆

    # re: DotNetZip 1.3 無法使用

    開啟 DotNetZip.sln 後,會要求輸入密碼金鑰,亦找不到相關 DLL檔可使用
  • Cheeso 2009/2/10 下午 01:59 回覆

    # re: DotNetZip 1.3 Release (2008/2/5)

    DotNetZip has been updated. The current version is now v1.7.

    It now supports multi-byte chars in filenames, including big5, and other code pages.

    Also does ZIP64, for file lengths greater than 0xFFFFFFFF.

    free. open source

    get it at
    http://www.codeplex.com/DotNetZip/Release/ProjectReleases.aspx?ReleaseId=18985
  • chhuang 2009/2/10 下午 11:03 回覆

    # re: DotNetZip 1.3 Release (2008/2/5)

    Thank you, Cheeso.

    I have published the latest news about DotNetZip 1.7 in DotNetZip 1.7 Release (2009/2/10) .

  • sheng 2009/6/3 下午 11:42 回覆

    # re: DotNetZip 1.3 Release (2008/2/5)

    using (ZipFile zip = ZipFile.Read(sourcefile))
    {
    foreach (ZipEntry ze in zip)
    {
    ze.Extract(targetFolderPath);
    }
    }
    請問您有遇到Extract後中文檔名變亂碼的情況嗎?
    如何解決?thanks
標題 *
名稱 *
Email (將不會被顯示)
Url
回應
登入後使用進階評論
Please add 2 and 7 and type the answer here: