0

I have this code:

using (var zip = new ZipFile())
{
    zip.CompressionLevel = CompressionLevel.None;
    zip.AddDirectory(myDirectoryInfo.FullName);
    zip.UseZip64WhenSaving = Zip64Option.Always;
    zip.SaveProgress += SaveProgress;
    zip.Save(outputPackage);
}

private void SaveProgress(object sender, SaveProgressEventArgs e)
{
    if (e.EntriesTotal > 0 && e.EntriesSaved > 0)
    {
        var counts = String.Format("{0} / {1}", e.EntriesSaved, e.EntriesTotal);
        var percentcompletion = ((double)e.EntriesSaved / e.EntriesTotal) * 100;
    }
}

What I really want to do is estimate the time remaining for the packaging to complete. But in SaveProgress the SaveProgressEventArgs values BytesTransferred and TotalBytesToTransfer have values of 0. I believe I need these to accurately estimate time?

So first, am I supposed to have values from these? Seems like the packaging is working okay. Second, what's the best way to estimate time remaining here, and third, is there a way to ensure that this is the fastest way to package a large directory? I don't want to compress- this is a directory filled with already compressed files that just need to be stuffed into an archive.

Nicros
  • 5,031
  • 12
  • 57
  • 101
  • The `BytesTransferred` is the number of bytes **between two entries** (thus ticks), so you should maintain a state and add these to the "already processed bytes". – Willem Van Onsem Jun 25 '14 at 02:16
  • Take a look at: http://stackoverflow.com/questions/22976841/how-to-report-progress-while-creating-a-zip-file – Willem Van Onsem Jun 25 '14 at 02:19
  • Did you try that code in the other answer? I did. It doesn't work for the reason I describe above, the value of `BytesTransferred` is always 0, regardless of progress in `SaveProgress`. If you have a better explanation, I would love to see it. – Nicros Jun 25 '14 at 05:38

0 Answers0