// 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.Collections; using System.IO; using ICSharpCode.SharpZipLib.Zip; namespace E { public class Program { public static void Unzip(string fnm, string dir) { ZipFile zf = new ZipFile(fnm); foreach(ZipEntry ze in zf) { string fullloc = Path.Combine(dir, ze.Name.Replace('/', Path.DirectorySeparatorChar)); string locdir = Path.GetDirectoryName(fullloc); if(!Directory.Exists(locdir)) { Directory.CreateDirectory(locdir); } if(!fullloc.EndsWith(Path.DirectorySeparatorChar.ToString())) { Stream istm = zf.GetInputStream(ze); Stream ostm = new FileStream(fullloc, FileMode.CreateNew, FileAccess.Write); byte[] b = new byte[100000]; int n; while((n = istm.Read(b, 0, b.Length)) > 0) { ostm.Write(b, 0, n); } ostm.Close(); } } zf.Close(); } public static void Main(string[] args) { Unzip(@"C:\e\z.zip", @"C:\e\zz"); } } }