这是来自实际项目的代码,用于该问题,因此一些数据是硬编码的:
static void Main(string[] args)
{
Console.WriteLine("Starting. " + Environment.Version);
using (var stream = new FileStream(@"stream_test.txt", FileMode.Open))
{
stream.Position = 0;
// .NET implements Deflate (RFC 1951) but not zlib (RFC 1950),
// so we have to skip the first two bytes.
stream.ReadByte();
stream.ReadByte();
var zipStream = new DeflateStream(stream, CompressionMode.Decompress, true);
// Hardcoded length from real project. In the previous .Net versions this is size of final result
long bytesToRead = (long)262 * 350;
var buffer = new byte[bytesToRead];
int …Run Code Online (Sandbox Code Playgroud)