CompressionLevel 열거형
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
압축 시 속도를 우선할지 압축 크기를 우선할지를 나타내는 값을 지정합니다.
public enum class CompressionLevel
public enum CompressionLevel
type CompressionLevel =
Public Enum CompressionLevel
- 상속
필드
Fastest | 1 | 압축 작업은 결과 파일이 최적으로 압축되지 않더라도 가능한 신속하게 완료되어야 합니다. |
NoCompression | 2 | 파일에 대해 압축을 수행할 수 없습니다. |
Optimal | 0 | 압축 작업은 압축 속도와 출력 크기의 균형을 최적으로 조정해야 합니다. |
SmallestSize | 3 | 압축 작업은 작업을 완료하는 데 시간이 오래 걸리더라도 가능한 한 작은 출력을 만들어야 합니다. |
설명
압축 작업에는 일반적으로 속도와 압축 효과 간의 절충이 포함됩니다. 열거형을 CompressionLevel 사용하여 개발 시나리오에서 더 중요한 요소, 즉 압축 작업을 완료하는 시간 또는 압축된 파일의 크기를 나타냅니다. 이러한 값은 특정 압축 수준에 해당하지 않습니다. 압축을 구현하는 개체는 압축을 처리하는 방법을 결정합니다.
다음 메서드, DeflateStream, GZipStreamZipFileZipArchive및 ZipFileExtensions 클래스에는 압축 수준을 지정할 수 있는 매개 compressionLevel
변수가 포함됩니다.
DeflateStream.DeflateStream(Stream, CompressionLevel, Boolean)
ZipFile.CreateFromDirectory(String, String, CompressionLevel, Boolean)
ZipFileExtensions.CreateEntryFromFile(ZipArchive, String, String, CompressionLevel)
예제
다음 예제에서는 클래스를 사용하여 ZipFile zip 보관 파일을 만들 때 압축 수준을 설정하는 방법을 보여 있습니다.
using System;
using System.IO;
using System.IO.Compression;
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
string startPath = @"c:\example\start";
string zipPath = @"c:\example\result.zip";
ZipFile.CreateFromDirectory(startPath, zipPath, CompressionLevel.Fastest, true);
}
}
}
Imports System.IO
Imports System.IO.Compression
Module Module1
Sub Main()
Dim startPath As String = "c:\example\start"
Dim zipPath As String = "c:\example\result.zip"
ZipFile.CreateFromDirectory(startPath, zipPath, CompressionLevel.Fastest, True)
End Sub
End Module