My code is creating archives from csv-files. Some of which are potentially empty. The Problem is, that archives created from empty files are not password protected, although a password is provided. With non empty files it works perfectly well.
As far as i understand this is the intended functionality of DotNetZip, as it checks for zero-length input before applying encryption. However the recipient of the archives needs the files entirely password protected without exception.
This is the code I use:
ZipFile zip;
if (File.Exists(archive)) { zip = ZipFile.Read(archive); }
else { zip = new ZipFile(); }
using (zip)
{
if (password.Length > 0)
{
zip.Password = password;
}
zip.AddFile(file, pathInArchive);
zip.Save(archive);
}
Is there a workaround for this problem?