internal void Extract(string path, System.Threading.CancellationToken token) { _total = 0; _completed = 0; using var archive = SevenZipArchive.Open(_zipFile); //try //{ // archive.CompressedBytesRead += Archive_CompressedBytesRead; _total = archive.Entries.Sum(m => m.Size); foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory)) { token.ThrowIfCancellationRequested(); entry.WriteToDirectory(path, new ExtractionOptions() { ExtractFullPath = true, Overwrite = true }); _completed += entry.Size; UnzipProgressChanged?.Invoke(this, new SevenZipUnzipProgressArgs() { Progress = (float)_completed / _total }); //System.Diagnostics.Debug.WriteLine($"{_completed} {_total}"); } // } // catch (Exception) // { // throw; // } // finally // { // archive.CompressedBytesRead -= Archive_CompressedBytesRead; // } }
private void NotifyUnzipProgressChanged(long archiveSize, long bytesProcessed) { UnzipProgressChanged?.Invoke(this, new UnzipProgressChangedEventArgs(archiveSize, bytesProcessed)); }