// 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 System.IO.Compression; 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\sysiocmp.zip", FileMode.Create, FileAccess.Write)) { using(ZipArchive za = new ZipArchive(fs, ZipArchiveMode.Create)) { ZipArchiveEntry tzae = za.CreateEntry("xxx/test.txt"); using(StreamWriter sw = new StreamWriter(tzae.Open())) { for(int i = 0; i < REP; i++) { sw.WriteLine(text); } } ZipArchiveEntry bzae = za.CreateEntry("xxx/test.bin"); using(Stream s = bzae.Open()) { for(int i = 0; i < REP; i++) { s.Write(buf, 0, buf.Length); } } } } } } }