title: DotNetZip - Display progress of extraction?
body: <p>This problem is solved. My mistake was that within my second block of code I was using SaveProgress instead of ExtractProgress and I was using Zip.ExtractAll before setting up the Event Handler. Thanks to <a href="https://stackoverflow.com/users/6457540/bradley-moorfield">Bradley Moorfield</a> for helping me.</p>
  
  <p>So I'm using the DotNetZip library to compress/extract zip files throughout my code. I was able to accomplish showing the percentage of compression with this code:</p>
  
  <pre><code>                using (ZipFile zip = new ZipFile())
                  {
                      zip.AddDirectory(filePath);
                      var mb = GetDirectorySize(filePath) / 1048576;
                      long timesRunNeeded = mb / 100;
                      if (mb % 100 &gt; 0) { timesRunNeeded++; }
                      if (mb &lt;= 100) { timesRunNeeded = 1; }
                      int timesRun = 1;
                      int pastP = 0;
                      zip.SaveProgress += (o, args) =&gt;
                      {
                          var percentage = (int)(1.0d / args.TotalBytesToTransfer * args.BytesTransferred * 100.0d);
                          if (pastP != percentage)
                          {
                              clearLine();
                              setColor(ConsoleColor.Gray); Console.Write("   Percentage: "); setColor(ConsoleColor.Green);
                              Console.Write(percentage + " [" + timesRun + "/" + timesRunNeeded + "]");
                              if ((percentage == 100) &amp;&amp; (pastP &gt;= 0) &amp;&amp; (pastP &lt;= 99))
                              {
                                  timesRun++;
                              }
                          }
                          pastP = percentage;
                      };
                      zip.Save(filePath + ".zip");
                  }
  </code></pre>
  
  <p>The reason it is like this is beacuse it compresses 100 mb at a time, so for example, if a folder was 2153 mb, it'd go to 100% 22 times. This is all working perfectly, and I like the way I have it, however I'm having some trouble displaying the percentage done when extracting from a zip to a directory.
  Here's my code so far:</p>
  
  <pre><code>                        using (ZipFile zip = ZipFile.Read(filePath))
                          {
                              Directory.CreateDirectory(filePath.Replace(".zip", ""));
                              zip.ExtractAll(filePath.Replace(".zip", ""), ExtractExistingFileAction.OverwriteSilently);
                              zip.SaveProgress += (o, args) =&gt;
                              { //Fix this, not showing percentage of extraction.
                                  var percentage = (int)(1.0d / args.TotalBytesToTransfer * args.BytesTransferred * 100.0d);
                                  clearLine();
                                  Console.Write(percentage);
                              };
                          }
  </code></pre>
  
  <p>For whatever reason, this code doesn't print any percentage at all, so I'm guessing it's got something to do with the way I'm actually calculating the percentage. Should it be different when compressing vs extracting? Thanks in advance.</p>