I have the following code working for a single file zip without any problems. But when I zip (create) from a directory the progressbar goes nuts.
Basically, the progressbar goes back and forward nonstop. The image illustrates.
Inside the folder selected I might have like another 10 sub-folders.
using (ZipFile zip = new ZipFile())
{
zip.CompressionLevel = Ionic.Zlib.CompressionLevel.BestCompression;
zip.SaveProgress += zipProgress;
zip.AddDirectory(folderPath);
zip.Save(tempPath);
}
private void zipProgress(object sender, SaveProgressEventArgs e)
{
if (e.EventType == ZipProgressEventType.Saving_EntryBytesRead)
this.progressbar1.Value = (int)((e.BytesTransferred * 100) / e.TotalBytesToTransfer);
else if (e.EventType == ZipProgressEventType.Saving_Completed)
this.progressbar1.Value = 100;
}
I do realize that the fact of progress value continuously goes forward and back is due to the fact that I'm zipping one folder that contains 10 sub-folders.
However i would like to know if there's any way of properly show the progressbar for folder zipping?