how to remove a zip password?

Mar 2, 2012 at 1:24 PM


I am using ur control and it is amazing.

I want to allow user of removing his archive password, change it, or set one foor unprotected archive.

How  to d it?


Mar 2, 2012 at 3:51 PM

try this code:

here what i have done:
1. first you need to extract all files from archive to temp folder with given password.
2. then add files and set a new password again
3. delete the temp folder.

    using (var zip = new ZipFile(@"C:\zip\"))
                foreach (ZipEntry entry in zip)
                    //Unzip all files with password to a temp
                    entry.ExtractWithPassword(@"C:\zip\Temp", "oldpass");
            //Now zip with you new password
            using (var zip = new ZipFile())
                foreach (string file in Directory.GetFiles(@"C:\zip\Temp"))
                    ZipEntry entry = zip.AddFile(file);
                    entry.Password = "newpass";

please let me know in case of any concerns.

Mar 2, 2012 at 6:37 PM

Thx sir, I know that, I am searching for a simple function to do that. as this method requries full extraction and rebuilding of an archive qwhich is a terrible thing with 5GB archives.

Mar 13, 2012 at 12:21 AM

The password in a zipfile is used to encrypt the entry data.  As a result, "removing a password" involves decrypting the entry data, and then rewriting the unencyrpted entry data back into a zip  file.  There is no other way around this "terrible thing".