sujith karivelil
sujith karivelil

Reputation: 29036

password option is not working in Zip file

Am creating a Password enabled zip file using DotNetZip Library following is the code for this:

using (ZipFile zip = new ZipFile())
{
    string[] Files = Directory.GetFiles(cryptPath, "*.*");
    foreach (string f in Files)
    {
        zip.AddFile(f);                       
    }                   
    zip.Password = "mypassord";
    zip.Save(cryptPath + @"\output.zip");
}

Everything works fine except the password option is not working, no password is prompted while opening the file? how can i enable this?

Upvotes: 1

Views: 3567

Answers (1)

Volkan Paksoy
Volkan Paksoy

Reputation: 6977

It seems to be using the password for encryption when you add the files so setting the password before adding the files worked for me:

using (ZipFile zip = new ZipFile())
{
    zip.Password = "mypassword";

    string[] Files = Directory.GetFiles(cryptPath, "*.*");
    foreach (string f in Files)
    {
        zip.AddFile(f);                       
    }                   

    zip.Save(cryptPath + @"\output.zip");
}

Upvotes: 12

Related Questions