CompressionLevel 列挙型

定義

圧縮操作で速度と圧縮サイズのどちらを重視するかを示す値を指定します。

public enum class CompressionLevel
public enum CompressionLevel
type CompressionLevel = 
Public Enum CompressionLevel
継承
CompressionLevel

フィールド

名前 説明
Optimal 0

圧縮操作では、圧縮速度と出力サイズのバランスを最適に調整する必要があります。

Fastest 1

圧縮操作は、結果のファイルが最適に圧縮されていない場合でも、できるだけ早く完了する必要があります。

NoCompression 2

ファイルに対して圧縮を実行する必要はありません。

SmallestSize 3

圧縮操作では、操作の完了に時間がかかる場合でも、出力は可能な限り小さくする必要があります。

注釈

圧縮操作には、通常、圧縮の速度と有効性のトレードオフが伴います。 CompressionLevel列挙体を使用して、開発シナリオで最も重要な要素 (圧縮操作を完了する時間または圧縮ファイルのサイズ) を示します。 これらの値は、特定の圧縮レベルに対応していません。圧縮を実装するオブジェクトによって、それらの処理方法が決まります。

DeflateStreamGZipStreamZipArchiveZipFile、および ZipFileExtensions クラスの次のメソッドには、圧縮レベルを指定できる 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

適用対象