从C++到C#的zlib,如何将byte []转换为流并将流转换为byte [],可以使用以下步骤:
using System.IO.Compression;
byte[] inputBytes = new byte[] { /* 输入的byte数组 */ };
MemoryStream inputStream = new MemoryStream(inputBytes);
MemoryStream outputStream = new MemoryStream();
using (DeflateStream deflateStream = new DeflateStream(inputStream, CompressionMode.Decompress))
{
deflateStream.CopyTo(outputStream);
}
byte[] outputBytes = outputStream.ToArray();
using System.IO.Compression;
byte[] inputBytes = new byte[] { /* 输入的byte数组 */ };
MemoryStream inputStream = new MemoryStream(inputBytes);
MemoryStream outputStream = new MemoryStream();
using (DeflateStream deflateStream = new DeflateStream(outputStream, CompressionMode.Compress))
{
inputStream.CopyTo(deflateStream);
}
byte[] outputBytes = outputStream.ToArray();
以上就是从C++到C#的zlib,如何将byte []转换为流并将流转换为byte []的方法。
领取专属 10元无门槛券
手把手带您无忧上云