Behavior defined:
from http://cheeso.members.winisp.net/DotNetZipHelp/html/91d797c7-efff-99a3-2b14-6c9a9797b324.htm
RecordsExtracted The amount of data retrieved. This is set only if the EventType is Extracting_BeforeExtractEntry or Extracting_AfterExtractEntry, and Extract () occurs in the scope of the ExtractAll () call.
The reason for this is simple: if you call Extract () in a loop that you yourself control, there is no way for the library to find out how many times you plan to call it, how many times you called it in a row, whether to read the first 5 times with the next 5 times and so on. Therefore, DotNetZip cannot give you reliable information about how much you have done.
You have two simple solutions:
use an int counter that you increment for every call to Extract () in your loop.
calling ExtractAll (), in which case it will throw ExtractProgressEvents with the EntriesExtracted
value set to a significant number.
option 1:
int n; using(ZipFile zip = ZipFile.Read(zipFile)) { zip.ExtractProgress += zip_ExtractProgress; n = 0; foreach (ZipEntry entry in zip) { n++; entry.Extract(destination, ExtractExistingFileAction.OverwriteSilently); } Console.WriteLine("DONE"); }
option 2:
using(ZipFile zip = ZipFile.Read(zipFile)) { zip.ExtractProgress += zip_ExtractProgress; zip.ExtractAll(destination, ExtractExistingFileAction.OverwriteSilently); Console.WriteLine("DONE"); }
Cheeso
source share