none
Problems with extracting Zip file using System.IO.Packaging

    Question

  • This is the code I have right now

    pZipFilename = "C:\\123\\1234.zip"
    Using pkgMain As Package = Package.Open(pZipFilename, FileMode.Open, FileAccess.Read)
         For Each pkgPart As PackagePart In pkgMain.GetParts()
         ...

    The problem I'm having is that pkgMain.GetParts() never returns anything even though the .zip file has around 100 items in it.

    Monday, February 13, 2012 4:52 PM

Answers

  • I would recommend looking at using DotNetZip instead of System.IO.Packaging to handle this.  The Packaging classes are somewhat restrictive on the zip files that they will open (which is likely why you are seeing this problem).  I've found third party solutions, such as DotNetZip, to be far nicer to use and more reliable.


    Reed Copsey, Jr. - http://reedcopsey.com
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    • Marked as answer by pwned555 Monday, February 13, 2012 5:23 PM
    Monday, February 13, 2012 5:11 PM

All replies

  • I would recommend looking at using DotNetZip instead of System.IO.Packaging to handle this.  The Packaging classes are somewhat restrictive on the zip files that they will open (which is likely why you are seeing this problem).  I've found third party solutions, such as DotNetZip, to be far nicer to use and more reliable.


    Reed Copsey, Jr. - http://reedcopsey.com
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    • Marked as answer by pwned555 Monday, February 13, 2012 5:23 PM
    Monday, February 13, 2012 5:11 PM
  • Thank you, DotNetZip does work and I have implemented it now, I was originally hoping to do it without using a 3rd party solution but I guess that might not have been possible for my situation.
    Monday, February 13, 2012 5:23 PM