Skip to content

CompressionEngine Class

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

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.
PropertyDescription
CompressionLevelCompression level to use when compressing files.
UseTempFilesGets or sets a flag indicating whether temporary files are created and used during compression.
EventDescription
ProgressOccurs when the compression engine reports progress in packing or unpacking an archive.
WixToolset.Dtf.Compression.dll version 5.0.0+41e11442b2ca93e444b60213b5ae99dcbab787d8

Disposes of resources allocated by the compression engine.

public void Dispose()

Disposes of resources allocated by the compression engine.

protected void Dispose(
bool disposing
)
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.

Disposes the compression engine.

protected void Finalize()

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

public System.Int64 FindArchiveOffset(
System.IO.Stream stream
)
ParameterTypeDescription
streamSystem.IO.StreamA stream for reading the archive.

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

The archive must begin on a 4-byte boundary.

Gets information about all files in an archive stream.

public IList<WixToolset.Dtf.Compression.ArchiveFileInfo> GetFileInfo(
System.IO.Stream stream
)
ParameterTypeDescription
streamSystem.IO.StreamA stream for reading the archive.

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

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

Gets the list of files in an archive Stream.

public IList<System.String> GetFiles(
System.IO.Stream stream
)
ParameterTypeDescription
streamSystem.IO.StreamA stream for reading the archive.

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

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

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

public bool IsArchive(
System.IO.Stream stream
)
ParameterTypeDescription
streamSystem.IO.StreamStream for reading the archive file.

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

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

protected void OnProgress(
ArchiveProgressEventArgs e
)
ParameterTypeDescription
eArchiveProgressEventArgsEvent details.

Reads a single file from an archive stream.

public System.IO.Stream Unpack(
System.IO.Stream stream,
string path
)
ParameterTypeDescription
streamSystem.IO.StreamA stream for reading the archive.
pathstringThe path of the file within the archive (not the external file path).

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

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

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

Compression level to use when compressing files.

public CompressionLevel CompressionLevel { get; set; }

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

public bool UseTempFiles { get; set; }

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.

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

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

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

  • T:WixToolset.Dtf.Compression.ArchiveProgressType