public void ArchiveWithComment() { string path = this.startupPath; using (ZipArchive archive = new ZipArchive()) { foreach (string file in System.IO.Directory.EnumerateFiles(path)) { ZipFileItem zipFI = archive.AddFile(file, "/"); zipFI.Comment = "Archived by " + Environment.UserName; } archive.Save("Documents\\ArchiveWithComment.zip"); } }
public void ProtectPassword() { string[] sourcefiles = this.sourceFiles; string password = "******"; using (ZipArchive archive = new ZipArchive()) { foreach (string file in sourceFiles) { ZipFileItem zipFI = archive.AddFile(file, "/"); zipFI.EncryptionType = EncryptionType.Aes128; zipFI.Password = password; } archive.Save("Documents\\ProtectPassword.zip"); } }