為 ZIP 檔案設定密碼保護
為ZIP檔案設置密碼涉及新增密碼到檔案,以保護其中的內容安全。 這確保了只有擁有正確密碼的人才能解壓或存取ZIP檔案內的文件。這個密碼作為一種加密形式,防止未經授權存取儲存在檔案中的文件。若要從受密碼保護的ZIP檔案中解壓文件,使用者必須輸入正確的密碼。
準備好要開始了嗎?
Nuget 下載 22,086 | 版本: 2026.7 剛剛發布
using IronZip;
using IronZip.Enum;
// Create empty ZIP with highest compression
using (var archive = new IronZipArchive(9))
{
// Password protect the ZIP (Support AES128 & AES256)
archive.Encrypt("P@ssw0rd", EncryptionMethods.Traditional);
archive.Add("./assets/image1.jpg");
archive.Add("./assets/image2.jpg");
// Export the ZIP
archive.SaveAs("output.zip");
}
Imports IronZip
Imports IronZip.Enum
' Create empty ZIP with highest compression
Using archive = New IronZipArchive(9)
' Password protect the ZIP (Support AES128 & AES256)
archive.Encrypt("P@ssw0rd", EncryptionMethods.Traditional)
archive.Add("./assets/image1.jpg")
archive.Add("./assets/image2.jpg")
' Export the ZIP
archive.SaveAs("output.zip")
End Using
Install-Package IronZip
為ZIP檔案設置密碼涉及新增密碼到檔案,以保護其中的內容安全。 這確保了只有擁有正確密碼的人才能解壓或存取ZIP檔案內的文件。這個密碼作為一種加密形式,防止未經授權存取儲存在檔案中的文件。若要從受密碼保護的ZIP檔案中解壓文件,使用者必須輸入正確的密碼。