// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.IO; using ICSharpCode.SharpZipLib.Zip; namespace E { public class Program { private const int REP = 100; public static void Main(string[] args) { string text = "This is a little test !!!!"; byte[] buf = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; using(FileStream fs = new FileStream(@"C:\work\shrpzplb.zip", FileMode.Create, FileAccess.Write)) { using(ZipOutputStream zos = new ZipOutputStream(fs)) { ZipEntry tze = new ZipEntry("xxx/test.txt"); zos.PutNextEntry(tze); StreamWriter sw = new StreamWriter(zos); for(int i = 0; i < REP; i++) { sw.WriteLine(text); } sw.Flush(); // do not attempt to close ZipEntry bze = new ZipEntry("xxx/test.bin"); zos.PutNextEntry(bze); for(int i = 0; i < REP; i++) { zos.Write(buf, 0, buf.Length); } } } } } }