4
압축하지 않고 SharpZipLib을 사용하여 Zip 압축 파일에 파일을 추가하려면 어떻게합니까?압축하지 않고 SharpZipLib을 사용하여 아카이브에 파일을 추가하려면 어떻게합니까?
Google의 예는 매우 슬픈 것처럼 보입니다.
압축하지 않고 SharpZipLib을 사용하여 Zip 압축 파일에 파일을 추가하려면 어떻게합니까?압축하지 않고 SharpZipLib을 사용하여 아카이브에 파일을 추가하려면 어떻게합니까?
Google의 예는 매우 슬픈 것처럼 보입니다.
SetLevel
메서드 ZipOutputStream
클래스를 사용하여 압축 수준을 0으로 설정할 수 있습니다.
using (ZipOutputStream s = new ZipOutputStream(File.Create("test.zip")))
{
s.SetLevel(0); // 0 - store only to 9 - means best compression
string file = "test.txt";
byte[] contents = File.ReadAllBytes(file);
ZipEntry entry = new ZipEntry(Path.GetFileName(file));
s.PutNextEntry(entry);
s.Write(contents, 0, contents.Length);
}
편집 : 실제로 문서를 검토 한 후 훨씬 간단한 방법이 있습니다.
using (ZipFile z = ZipFile.Create("test.zip"))
{
z.BeginUpdate();
z.Add("test.txt", CompressionMethod.Stored);
z.CommitUpdate();
}