Using ZIPLIB
CodeKeep C# Feed Maggio 27th, 2008
Description: How to use the ziplib on the fly
Link: http://www.codekeep.net/snippets/dc6c17a3-4d8d-4fb9-9e08-7592b2a8c377.aspx
using System;
using System.IO;
using ICSharpCode.SharpZipLib.Core;
using ICSharpCode.SharpZipLib.Zip;
class MainClass
{
public static void Main(string[] args)
{
string[] filenames = Directory.GetFiles(args[0]);
byte[] buffer = new byte[4096];
using ( ZipOutputStream s = new ZipOutputStream(File.Create(args[1])) ) {
s.SetLevel(9); // 0 - store only to 9 - means best compression
foreach (string file in filenames) {
ZipEntry entry = new ZipEntry(file);
s.PutNextEntry(entry);
using (FileStream fs = File.OpenRead(file)) {
StreamUtils.Copy(fs, s, buffer);
}
}
}
}
}






