public void ExtractAll() {
// uncompress repository
String zippedPath = @"C:\test\archive.zip";
StringBuilder newPath = new StringBuilder(@"C:\test\extraction_test\");
ZipInputStream zipIn = new ZipInputStream(File.OpenRead(zippedPath));
DecompressArchive(newPath, zipIn);
}
private void DecompressArchive(StringBuilder newPath, ZipInputStream zipIn) {
ZipEntry entry;
while ((entry = zipIn.GetNextEntry()) != null) {
if (entry.Name.EndsWith("/")) {
Directory.CreateDirectory(String.Format("{0}{1}", newPath, entry.Name.Replace(@"/", @"\")));
}
else {
FileStream streamWriter = File.Create(String.Format("{0}{1}", newPath, entry.Name.Replace(@"/", @"\")));
long size = entry.Size;
byte[] data = new byte[size];
while (true) {
size = zipIn.Read(data, 0, data.Length);
if (size > 0) streamWriter.Write(data, 0, (int)size);
else break;
}
streamWriter.Close();
}
}
}