小编Dim*_*msa的帖子

.Net 6 System.IO.压缩问题有任何解决方法吗?DeflateStream.Read 方法在 .Net 6 中工作不正确,但在旧版本中工作正常

这是来自实际项目的代码,用于该问题,因此一些数据是硬编码的:

   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)

c# compression .net-6.0

2
推荐指数
1
解决办法
2307
查看次数

标签 统计

.net-6.0 ×1

c# ×1

compression ×1