This project is read-only.


Any error causes ZipException, not just invalid file formats


There's an inconsistency between the documentation and implementation. Currently any exception when creating a new ZipFile object will cause a ZipException to occur. However, this is documented as happening if there's an invalid file format. For example, this test demonstrates a valid file causing this exception.
    public void FileNotAvailableFails()
        const string tempFile = @"c:\";
        using (var zipfile = new ZipFile(tempFile)) { zipfile.Save(); }
            using (new FileStream(tempFile, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None))
                Assert.Throws(typeof(IOException), () => { using (new ZipFile(tempFile)) { } });
At a minimum, the documentation should be changed to indicate the inner exception indicates the real cause of the problem and the invalid file format description removed.
Ideally, any exception that is not due to an invalid file format should not be trapped and only things related to a bad file should be wrapped with the ZipException.
Closed Jun 14, 2011 at 4:22 AM by Cheeso
fixed in changeset 79081. First binary with this change: v1.9.1.6


Cheeso wrote Jun 14, 2011 at 4:21 AM

Good bug. The exception message now reads "Could not read {0} as a zip file" and the inner exception provides additional information.

wrote Jun 14, 2011 at 4:22 AM

wrote Feb 22, 2013 at 2:43 AM

wrote May 16, 2013 at 1:31 PM