private bool ExtractUpdate(int updateNumber, int updateMaxNumber,
double progress, double maxProgress,
string archiveFilenameIn, string outFolder, bool DeleteAfterExtract)
{
try {
using (var zf = new ZipFile(archiveFilenameIn)) {
int zEntryNumber = 1;
foreach (ZipEntry zipEntry in zf) {
OnStatusChanged(UpdateStatusEventArgs.Stage.EXTRACTING, updateNumber, updateMaxNumber, progress, maxProgress, zEntryNumber, zf.Count);
if (!zipEntry.IsFile) {
continue;
}
byte[] buffer = new byte[4096];
Stream zipStream = zf.GetInputStream(zipEntry);
string fullZipToPath = Path.Combine(outFolder, zipEntry.Name);
string directoryName = Path.GetDirectoryName(fullZipToPath);
if (directoryName.Length > 0) {
Directory.CreateDirectory(directoryName);
}
using (FileStream streamWriter = File.Create(fullZipToPath)) {
StreamUtils.Copy(zipStream, streamWriter, buffer);
}
zEntryNumber++;
}
}
} catch (ZipException) {
return false;
}
if (DeleteAfterExtract) {
try {
File.Delete(archiveFilenameIn);
} catch {
}
}
return true;
}