zip file not created with password and encryption

Feb 10, 2014 at 5:53 AM
Edited Feb 10, 2014 at 5:55 AM
Hi,
When I use the below code zip file is created but when I unzip it from F drive in unzipped without asking password and also without any encryption.
I restore that database and I was successful in restoring it.

I added dotnetzip library from nuget after installing it names as Ionic.Zip and its version is 1.9.2.0 and Runtime version is v2.0.50727

My project is empty asp.net application in VS 2013 and my operating system is windows 8

What I am doing wrong.

Used code from this URL http://dotnetzip.codeplex.com/wikipage?title=CS-Examples
Create a Zip archive that uses WinZip-compatible AES encryption.

My code is this
using Ionic.Zip;
using Ionic;

using (ZipFile zip = new ZipFile())
        {
            zip.CompressionLevel = Ionic.Zlib.CompressionLevel.BestCompression;
            zip.AddFile(@"F:\\TestDotnetzip.bak"); 
            zip.Password = "123456";
            zip.Encryption = EncryptionAlgorithm.WinZipAes256;
            zip.Save(@"F:\\TestDotnetzip.zip");
        }
May 15, 2014 at 1:25 PM
Did you found the solution ? I am facing the same problem.
May 16, 2014 at 1:47 AM
ya

write code like this for password protection

using (ZipFile zip = new ZipFile())
{
        zip.CompressionLevel = Ionic.Zlib.CompressionLevel.BestCompression;
        zip.AddFile(@"F:\\TestDotnetzip.bak").Password = "123456";
        zip.Encryption = EncryptionAlgorithm.WinZipAes256;
        zip.Save(@"F:\\TestDotnetzip.zip");
}

this will work
May 16, 2014 at 1:47 AM
ya

write code like this for password protection

using (ZipFile zip = new ZipFile())
{
    zip.CompressionLevel = Ionic.Zlib.CompressionLevel.BestCompression;
    zip.AddFile(@"F:\\TestDotnetzip.bak").Password = "123456";
    zip.Encryption = EncryptionAlgorithm.WinZipAes256;
    zip.Save(@"F:\\TestDotnetzip.zip");
}

this will work
Jun 9, 2014 at 10:53 AM
Incase someone need to add multiple files with password and not saving the original directory on the zipfile.
using (Ionic.Zip.ZipFile zip1 = new Ionic.Zip.ZipFile(zipFileName))
            {
                zip1.CompressionLevel = Ionic.Zlib.CompressionLevel.BestCompression;
                zip1.Password = "abc12345";
                zip1.AddFiles(filenames ,false,"");
                zip1.Encryption = Ionic.Zip.EncryptionAlgorithm.WinZipAes256;
                zip1.Save();
                
            }