A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.microsoft.com/en-us/dotnet/api/system.io.compression.compressionlevel below:

CompressionLevel Enum (System.IO.Compression) | Microsoft Learn

CompressionLevel Enum Definition

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
Inheritance
Fields Name Value Description Optimal 0

The compression operation should optimally balance compression speed and output size.

Fastest 1

The compression operation should complete as quickly as possible, even if the resulting file is not optimally compressed.

NoCompression 2

No compression should be performed on the file.

SmallestSize 3

The compression operation should create output as small as possible, even if the operation takes a longer time to complete.

Compression operations usually involve a tradeoff between the speed and the effectiveness of compression. 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. These values do not correspond to specific compression levels; the object that implements compression determines how to handle them.

The following methods of the DeflateStream, GZipStream, ZipArchive, ZipFile, and ZipFileExtensions classes include a parameter named compressionLevel that lets you specify the compression level:

Examples

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

Collaborate with us on GitHub

The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide. In this article

Was this page helpful?


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4