C# 使用LZ4Net进行压缩

C# 使用LZ4Net进行压缩,c#,compression,lz4,C#,Compression,Lz4,我试图用lz4net压缩多个文件,但我甚至不知道如何开始 我有string[]或List和文件路径(以及相对路径),并希望使用lz4将其压缩为一个文件 稍后,我想对其进行解压缩,同时考虑相关路径。下载 为每个文件创建缓冲区: public byte[] FileToByteArray(string fileName) { byte[] buff = null; FileStream fs = new FileStream(fileName, FileMode.Open, File

我试图用lz4net压缩多个文件,但我甚至不知道如何开始

我有
string[]
List
和文件路径(以及相对路径),并希望使用lz4将其压缩为一个文件

稍后,我想对其进行解压缩,同时考虑相关路径。

下载

为每个文件创建缓冲区:

public byte[] FileToByteArray(string fileName)
{
    byte[] buff = null;
    FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
    BinaryReader br = new BinaryReader(fs);
    long numBytes = new FileInfo(fileName).Length;
    buff = br.ReadBytes((int)numBytes);
    return buff;
}
然后,使用缓冲区按如下方式进行commpress/解压缩:

LZ4.LZ4Codec.Decode(input, offset, inputLength, outputLength); // Decoder
LZ4.LZ4Codec.Encode(input, offset, inputLength); // Encoder
如果您正在查找LZ4DLL的(包括帧压缩)