I'm trying to password protect a zip file using DotNetZip. But it doesn't work. It creates the zip just fine, but if i open it using 7zip I can extract the files without a password. Here is the code I'm using.
using (ZipFile zip = new ZipFile())
{
zip.Password = password;
zip.Encryption = EncryptionAlgorithm.WinZipAes256;
zip.CompressionLevel = Ionic.Zlib.CompressionLevel.BestSpeed;
// Adding folders in the base directory
foreach (var item in Directory.GetDirectories(someFilePath))
{
string folderName = new DirectoryInfo(item).Name;
zip.AddDirectory(item, folderName);
}
// Adding files in the base directory
foreach (string file in Directory.GetFiles(someFilePath))
{
zip.AddFile(file, "");
}
zip.Save(someFilePath);
}
Okay, I fixed it. I downloaded an older version of the DotNetZip dll.
I was previously using version 1.12 and it didn't work.
Using version 1.10.1 and the created zip is password protected