This project is read-only.

RemoveEntry from PW Protected Zip

May 27, 2009 at 7:32 PM

I am creating a password-protected zip containing a number of files and then later allowing the user to select files to remove from the zip.  This works fine if the zip is not password protected, but if I password protect the zip when I create it (sample code below) I get "FileNotFoundException" ("file2.txt") when I later remove a file from the zip and try to save it.


    Sub AddFiles()
        Dim zip As New Ionic.Zip.ZipFile()
        zip.Password = "password"
        zip.Encryption = Ionic.Zip.EncryptionAlgorithm.WinZipAes256
        Dim entry1 As Ionic.Zip.ZipEntry = zip.AddFile("c:\file1.txt")
    End Sub

    Sub RemoveFile()
        Dim zip As New Ionic.Zip.ZipFile(ZipFileName)
    End Sub

May 27, 2009 at 9:04 PM

Taking your code, I could not reproduce the "FileNotFoundException" you reported. 

Using v1.8.3.11, your code works, as expected.

Using v1.7.2.20, when I call Save() after removing an entry from a password protected file, I get an exception, but not the one you reported.  I get, instead, Ionic.Zip.BadPasswordException .  This seems like a bug, but it is not the problem you reported.

What version of the library are you using?


May 27, 2009 at 9:36 PM

I was using  When I switched to, the code worked fine, just as you said. 

Thanks for your help.

May 27, 2009 at 10:17 PM

Glad you got it working. After some further testing I was able to reproduce that FileNotFoundException.  It's a bug, that was fixed in v1.8 but the fix was not back-ported to v1.7. I'm doing that now.

May 27, 2009 at 10:29 PM

Thanks for the follow-up.  I'll give v1.7 a try after it's updated.

May 27, 2009 at 11:02 PM

v1.7.2.21 is now available.  It has this fix.