Class CompressionHelper
A set of helper functions for compressing and decompressing data
Inherited Members
Namespace: LemonEdge.Utils
Assembly: LemonEdge.Utils.dll
Syntax
public static class CompressionHelper
Methods
CompressFile(byte[]?)
Compresses raw byte data
Declaration
public static Task<byte[]> CompressFile(byte[]? data)
Parameters
Type | Name | Description |
---|---|---|
byte[] | data | The data to compress |
Returns
Type | Description |
---|---|
Task<byte[]> | The data compressed |
CompressFile(FileInfo)
Compresses the contents of a given file and returns the compressed data
Declaration
public static Task<byte[]> CompressFile(FileInfo originalFile)
Parameters
Type | Name | Description |
---|---|---|
FileInfo | originalFile | The file to compress |
Returns
Type | Description |
---|---|
Task<byte[]> | The contents of a file compressed |
CompressFile(Stream)
Compresses the data from a given stream
Declaration
public static Task<byte[]> CompressFile(Stream data)
Parameters
Type | Name | Description |
---|---|---|
Stream | data | The stream to compress |
Returns
Type | Description |
---|---|
Task<byte[]> | The compressed data |
CompressFile(StringBuilder, Encoding)
Compresses the given text using the specified encoding
Declaration
public static Task<byte[]> CompressFile(StringBuilder fileData, Encoding encoding)
Parameters
Type | Name | Description |
---|---|---|
StringBuilder | fileData | The text to compress |
Encoding | encoding | The encoding to use |
Returns
Type | Description |
---|---|
Task<byte[]> | The text compressed |
CompressFileToStream(Stream, Stream)
Compresses the file stream to a new stream
Declaration
public static Task CompressFileToStream(Stream data, Stream compressTo)
Parameters
Type | Name | Description |
---|---|---|
Stream | data | The data to compress |
Stream | compressTo | The empty stream to compress the data to |
Returns
Type | Description |
---|---|
Task | A task indicating the completion of the operation |
DecompressFile(byte[], FileInfo)
Given some compressed data, this will decompress that data and write it to a specified file on disk
Declaration
public static Task DecompressFile(byte[] compressedData, FileInfo fileInfoToDecompressTo)
Parameters
Type | Name | Description |
---|---|---|
byte[] | compressedData | The compressed data to decompress |
FileInfo | fileInfoToDecompressTo | The file to compress the data into |
Returns
Type | Description |
---|---|
Task | A task representing the IO operation of writing the decompressed data to disk |
DecompressFileToStream(byte[]?, Stream)
Decompresses the file stream to a new stream
Declaration
public static Task DecompressFileToStream(byte[]? data, Stream decompressTo)
Parameters
Type | Name | Description |
---|---|---|
byte[] | data | The data to decompress |
Stream | decompressTo | The empty stream to decompress the data to |
Returns
Type | Description |
---|---|
Task | A task indicating the completion of the operation |