I want to encrypt a zip archive.
using (FileStream stream = File.Create(Filepath + Filename))
{
DefaultEncryptionSettings encryptionSettings = new DefaultEncryptionSettings();
encryptionSettings.Password = "123";
using (ZipArchive archive = new ZipArchive(stream, ZipArchiveMode.Create, false, null, null, encryptionSettings))
{
using (ZipArchiveEntry entry = archive.CreateEntry("document.txt"))
{
StreamWriter writer = new StreamWriter(entry.Open());
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(writer.BaseStream, this);
}
}
}
Now it seems to work. No idea why.