title: Extracting files from a Zip archive programmatically using C# and System.IO.Packaging
body: <p>I have a bunch of ZIP files that are in desperate need of some hierarchical reorganization and extraction.  What I can do, currently, is create the directory structure and move the zip files to the proper location.  The mystic cheese that I am missing is the part that extracts the files from the ZIP archive.</p>
  
  <p>I have seen the MSDN articles on the <code>ZipArchive</code> class and understand them reasonable well.  I have also seen the <a href="https://stackoverflow.com/questions/291406/extract-files-from-zip-file-with-vbscript">VBScript ways to extract</a>.  This is not a complex class so extracting stuff should be pretty simple.  In fact, it works "mostly".  I have included my current code below for reference.</p>
  
  <pre><code> using (ZipPackage package = (ZipPackage)Package.Open(@"..\..\test.zip", FileMode.Open, FileAccess.Read))
   {
      PackagePartCollection packageParts = package.GetParts();
      foreach (PackageRelationship relation in packageParts)
      {
         //Do Stuff but never gets here since packageParts is empty.
      }
   }
  </code></pre>
  
  <p>The problem seems to be somewhere in the <code>GetParts</code> (or Get<em>Anything</em> for that matter).  It seems that the package, while open, is empty.  Digging deeper the debugger shows that the private member _zipArchive shows that it actually has parts.  Parts with the right names and everything.  Why won't the <code>GetParts</code> function retrieve them?  I'ver tried casting the open to a ZipArchive and that didn't help.  Grrr.</p>