GZipStream은 .gz 파일을 만드는 데 사용할 수 있지만 .zip 파일과 다릅니다.
비밀번호로 보호 된 zip 파일을 만들려면 제 3 자 라이브러리로 이동해야합니다.
여기 GZipStream`이 .zip 파일을 만들지 않습니다,이 파일에 .gz 생성`, 보조 노트로
var sb = new System.Text.StringBuilder();
sb.Append("This is the text file...");
foreach (var item in listOfStrings)
sb.Append(item);
// sb now contains all the content that will be placed into
// the text file entry inside the zip.
using (var zip = new Ionic.Zip.ZipFile())
{
// set the password on the zip (implicitly enables encryption)
zip.Password = "Whatever.You.Like!!";
// optional: select strong encryption
zip.Encryption = Ionic.Zip.EncryptionAlgorithm.WinZipAes256;
// add an entry to the zip, specify a name, specify string content
zip.AddEntry("NameOfFile.txt", sb.ToString());
// save the file
zip.Save("MyFile.zip");
}
... DotNetZip 사용하여 작업을 수행하는 방법은 다음과 같습니다. 나는 그것이 당신이 실제로 원하는 것을 가정 할 것입니다. 그렇지 않다면 적절하게 질문을 수정하십시오. –
@scatman :이 질문에 대한 답변이 있으면 받아 들인 대답을 표시하십시오. 다른 질문이있는 경우 "질문하기"버튼을 사용하여 새 질문을 시작하십시오. 감사합니다 – NotMe
@scatman - Sharpziplib는 암호를 지원합니다 – Keltex