CompressionLevel Výčet
Definice
Určuje hodnoty, které určují, zda operace komprese zvýrazňuje rychlost nebo velikost komprese.Specifies values that indicate whether a compression operation emphasizes speed or compression size.
public enum class CompressionLevel
public enum CompressionLevel
type CompressionLevel =
Public Enum CompressionLevel
- Dědičnost
Pole
| Fastest | 1 | Kompresní operace by se měla dokončit co nejrychleji, a to i v případě, že výsledný soubor není optimálně komprimován.The compression operation should complete as quickly as possible, even if the resulting file is not optimally compressed. |
| NoCompression | 2 | U souboru by se neměla provádět komprese.No compression should be performed on the file. |
| Optimal | 0 | Kompresní operace by měla být optimálně komprimována i v případě, že dokončení operace trvá delší dobu.The compression operation should be optimally compressed, even if the operation takes a longer time to complete. |
Poznámky
Kompresní operace obvykle zahrnují kompromis mezi rychlostí a efektivitou komprese.Compression operations usually involve a tradeoff between the speed and the effectiveness of compression. Pomocí CompressionLevel výčtu označíte, který faktor je ve vývojovém scénáři důležitější: čas dokončení operace komprese nebo velikost komprimovaného souboru.You use the CompressionLevel enumeration to indicate which factor is more important in your development scenario: the time to complete the compression operation or the size of the compressed file. Tyto hodnoty neodpovídají specifickým úrovním komprese; objekt, který implementuje kompresi, určuje, jak je zpracovat.These values do not correspond to specific compression levels; the object that implements compression determines how to handle them.
Následující metody DeflateStream GZipStream tříd,, ZipArchive , ZipFile a ZipFileExtensions obsahují parametr s názvem compressionLevel , který umožňuje určit úroveň komprese:The following methods of the DeflateStream, GZipStream, ZipArchive, ZipFile, and ZipFileExtensions classes include a parameter named compressionLevel that lets you specify the compression level:
DeflateStream.DeflateStream(Stream, CompressionLevel, Boolean)
ZipFile.CreateFromDirectory(String, String, CompressionLevel, Boolean)
ZipFileExtensions.CreateEntryFromFile(ZipArchive, String, String, CompressionLevel)
PříkladyExamples
Následující příklad ukazuje, jak nastavit úroveň komprese při vytváření archivu ZIP pomocí ZipFile třídy.The following example shows how to set the compression level when creating a zip archive by using the ZipFile class.
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