private void Unzip_ExtractProgressChanged(object sender, ExtractProgressEventArgs e) { if (e.TotalBytesToTransfer != 0) { Bar1SetProgress(e.BytesTransferred, e.TotalBytesToTransfer); Arquivo_Bar.Update(); } }
public void Unzip(string TargetDir, string ZipToUnpack) { try { Arquivo_Bar.Width = 0; ZipFile zipFile = ZipFile.Read(ZipToUnpack); try { zipFile.ExtractProgress += new EventHandler <ExtractProgressEventArgs>(Unzip_ExtractProgressChanged); LArquivo.Visible = true; foreach (ZipEntry zipEntry in zipFile) { string fileName = zipEntry.FileName; if (fileName.Contains("/")) { int num2 = fileName.LastIndexOf("/"); fileName = fileName.Substring(num2 + 1); } if (!zipEntry.IsDirectory) { LArquivo.Text = fileName; LArquivo.Update(); Arquivo_Bar.Update(); zipEntry.Extract(TargetDir, ExtractExistingFileAction.OverwriteSilently); } else { Logger.Log("[ERROR EXTRACT]: " + zipEntry.FileName + " não existe."); } } } finally { Arquivo_Bar.Width = Arquivo_BarFixo.Width; if (zipFile != null) { zipFile.Dispose(); } } } catch (Exception) { } }