Skip to main content

CompressionEngine Class

Base class for an engine capable of packing and unpacking a particular compressed file format.

Methods

MethodDescription
Dispose()Disposes of resources allocated by the compression engine.
Dispose(disposing)Disposes of resources allocated by the compression engine.
Finalize()Disposes the compression engine.
FindArchiveOffset(stream)Gets the offset of an archive that is positioned 0 or more bytes from the start of the Stream.
GetFileInfo(stream)Gets information about all files in an archive stream.
GetFiles(stream)Gets the list of files in an archive Stream.
IsArchive(stream)Checks whether a Stream begins with a header that indicates it is a valid archive.
OnProgress(e)Called by sublcasses to distribute a packing or unpacking progress event to listeners.
Unpack(stream, path)Reads a single file from an archive stream.

Properties

PropertyDescription
CompressionLevelCompression level to use when compressing files.
UseTempFilesGets or sets a flag indicating whether temporary files are created and used during compression.

Events

EventDescription
ProgressOccurs when the compression engine reports progress in packing or unpacking an archive.

WixToolset.Dtf.Compression.dll version 5.0.2+aa65968c419420d32e3e1b647aea0082f5ca5b78

Dispose() Method

Disposes of resources allocated by the compression engine.

Declaration

public void Dispose()

Dispose(disposing) Method

Disposes of resources allocated by the compression engine.

Declaration

protected void Dispose(
bool disposing
)

Parameters

ParameterTypeDescription
disposingboolIf true, the method has been called directly or indirectly by a user's code, so managed and unmanaged resources will be disposed. If false, the method has been called by the runtime from inside the finalizer, and only unmanaged resources will be disposed.

Finalize() Method

Disposes the compression engine.

Declaration

protected void Finalize()

FindArchiveOffset(stream) Method

Gets the offset of an archive that is positioned 0 or more bytes from the start of the Stream.

Declaration

public System.Int64 FindArchiveOffset(
System.IO.Stream stream
)

Parameters

ParameterTypeDescription
streamSystem.IO.StreamA stream for reading the archive.

Return value

System.Int64 The offset in bytes of the archive, or -1 if no archive is found in the Stream.

Remarks

The archive must begin on a 4-byte boundary.

GetFileInfo(stream) Method

Gets information about all files in an archive stream.

Declaration

public IList<WixToolset.Dtf.Compression.ArchiveFileInfo> GetFileInfo(
System.IO.Stream stream
)

Parameters

ParameterTypeDescription
streamSystem.IO.StreamA stream for reading the archive.

Return value

IList<WixToolset.Dtf.Compression.ArchiveFileInfo> Information about all files in the archive stream.

Exceptions

ExceptionDescription
T:WixToolset.Dtf.Compression.ArchiveExceptionThe stream is not a valid
archive.

GetFiles(stream) Method

Gets the list of files in an archive Stream.

Declaration

public IList<System.String> GetFiles(
System.IO.Stream stream
)

Parameters

ParameterTypeDescription
streamSystem.IO.StreamA stream for reading the archive.

Return value

IList<System.String> A list of the paths of all files contained in the archive.

Exceptions

ExceptionDescription
T:WixToolset.Dtf.Compression.ArchiveExceptionThe stream is not a valid
archive.

IsArchive(stream) Method

Checks whether a Stream begins with a header that indicates it is a valid archive.

Declaration

public bool IsArchive(
System.IO.Stream stream
)

Parameters

ParameterTypeDescription
streamSystem.IO.StreamStream for reading the archive file.

Return value

bool True if the stream is a valid archive (with no offset); false otherwise.

OnProgress(e) Method

Called by sublcasses to distribute a packing or unpacking progress event to listeners.

Declaration

protected void OnProgress(
ArchiveProgressEventArgs e
)

Parameters

ParameterTypeDescription
eArchiveProgressEventArgsEvent details.

Unpack(stream, path) Method

Reads a single file from an archive stream.

Declaration

public System.IO.Stream Unpack(
System.IO.Stream stream,
string path
)

Parameters

ParameterTypeDescription
streamSystem.IO.StreamA stream for reading the archive.
pathstringThe path of the file within the archive (not the external file path).

Return value

System.IO.Stream A stream for reading the extracted file, or null if the file does not exist in the archive.

Remarks

The entire extracted file is cached in memory, so this method requires enough free memory to hold the file.

Exceptions

ExceptionDescription
T:WixToolset.Dtf.Compression.ArchiveExceptionThe stream is not a valid
archive.

CompressionLevel Property

Compression level to use when compressing files.

Declaration

public CompressionLevel CompressionLevel { get; set; } 

UseTempFiles Property

Gets or sets a flag indicating whether temporary files are created and used during compression.

Declaration

public bool UseTempFiles { get; set; } 

Remarks

The value of this property is true by default. Using temporary files can greatly reduce the memory requirement of compression, especially when compressing large archives. However, setting this property to false may yield slightly better performance when creating small archives. Or it may be necessary if the process does not have sufficient privileges to create temporary files.

Progress Event

Occurs when the compression engine reports progress in packing or unpacking an archive.

Declaration

public System.EventHandler<WixToolset.Dtf.Compression.ArchiveProgressEventArgs> Progress

Value

System.EventHandler<WixToolset.Dtf.Compression.ArchiveProgressEventArgs>

See also

  • T:WixToolset.Dtf.Compression.ArchiveProgressType