2009-11-06 5 views

답변

7

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(); 
} 
관련 문제