■ 案1:J#を使用して行う
http://dobon.net/vb/dotnet/links/createzipfile.htmlhttp://homepage2.nifty.com/nonnon/SoftSample/CS.NET/SampleJZip.html
などに記載されている方法
欠点
* J#はVisual Studio 2008以降ではなくなっているらしい。http://social.msdn.microsoft.com/Forums/ja-JP/vsgeneralja/thread/cafe4772-7bcb-4d29-87dd-25f600064d20/
■ 案2:GZipStream クラスを使用して行う
http://msdn.microsoft.com/ja-jp/library/system.io.compression.gzipstream.aspx欠点
* 一番いいと思ったのだが、gzip データ形式しかないっぽい。 * 複数ファイルを直接扱うことはできず、圧縮率もそれほど高くないらしいhttp://social.msdn.microsoft.com/Forums/ja-JP/vsgeneralja/thread/cafe4772-7bcb-4d29-87dd-25f600064d20/
サンプル
* .NET Framework 2.0 から追加された System.IO.Compression.GZipStream、System.IO.Compression.DeflateStream クラスを利用し ストリームでの圧縮・展開を行うhttp://code.msdn.microsoft.com/windowsdesktop/C-a8033833
■ 案3:DotNetZipを使用して行う
http://social.msdn.microsoft.com/Forums/ja-JP/vsgeneralja/thread/cafe4772-7bcb-4d29-87dd-25f600064d20/でよく使用されていると言ってる。
ライセンスについて
* ゆるいらしい。http://astel-labs.net/blog/diary/2010/06/100630-1.html
構文
Zip解凍using (ZipFile zip = ZipFile.Read( filePath1 // filePath1:保存元のパス , Encoding.GetEncoding("Shift_JIS") // 日本語を使用している場合、Shift-JISを指定する )) { // 解凍処理(全て解凍する場合) zip.ExtractAll(filePath2); // filePath2:保存先のパス // 解凍処理(ZIP内のファイルを順に取り出す場合) //foreach (ZipEntry entry in zip) //{ // //個々に解凍 // entry.Extract(filePath2); //} }Zip圧縮
using (ZipFile zip = new ZipFile(Encoding.GetEncoding("Shift_JIS"))) { // 圧縮レベルを設定 zip.CompressionLevel = CompressionLevel.BestCompression; // ファイルを追加 zip.AddDirectory(filePath1); // filePath1:保存元のパス // ZIPファイルを保存 zip.Save(filePath2); // filePath2:保存先のパス }
サンプル
* 以下の関連記事を参照。https://blogs.yahoo.co.jp/dk521123/20127299.html
参考資料
http://journal.mycom.co.jp/articles/2009/08/21/DotNetZip/001.htmlhttp://techbank.jp/Community/blogs/nora/archive/2009/08/23/12176.aspx
その他の方法
* 以下のサイトを参照。http://csharper.blog57.fc2.com/blog-entry-171.html
http://codezine.jp/article/detail/5266
http://www.infoq.com/jp/news/2008/07/7-Zip-from-.NET
http://niyodiary.cocolog-nifty.com/blog/2009/03/czip-d457.html#.A20090319_1_2
http://blog.kyotakahashi.com/?eid=250561
関連記事
Java
ZIP 処理 ~圧縮編~https://blogs.yahoo.co.jp/dk521123/33497835.html
ZIP 処理 ~解凍編~
https://blogs.yahoo.co.jp/dk521123/33645352.html
C#
C#でZIPに圧縮・解凍を扱うには ~ サンプルコード編 ~https://blogs.yahoo.co.jp/dk521123/20127299.html