DeflateStream类的问题 [英] Problem with DeflateStream class

查看:58
本文介绍了DeflateStream类的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试解码经过平面编码的pdf流.我得到一个例外:
索引超出了数组的范围.
我不明白,因为我尝试了准确无误.
希望您对此提供的帮助.

这是我正在使用的代码.
ASCIIEncoding编码=新的System.Text.ASCIIEncoding();解压缩(缓冲区);

公共静态字节[]解压缩(byte []数据) br>输入.Position = 0;

DeflateStream gzip = new DeflateStream(input,CompressionMode.Decompress,false);

input.ReadByte();
input.ReadByte();

MemoryStream输出= new MemoryStream();
byte [] buff = new byte [64];
int read = -1; );
的同时while(read> 0) ;
}
gzip.Close();
返回output.ToArray();
}

如果您没有测试就找不到任何内容,那么我可以上传正在处理的流文件.
我设法用PHP应用程序对其进行解码,因此接缝正确.

感谢您的帮助.

解决方案

将值发布到数据中.

I'm trying to decode a flatencoded pdf stream. I get the exception:
Index was outside the bounds of the array.
I don't understand because I have tried to be really exact.
I Would appreciate your help on this.

Here is the code I'm using.
            ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
            byte[] buffer=encoding.GetBytes(data);
     byte[] decomp = Decompress(buffer);

        public static byte[] Decompress(byte[] data)
        {
           
            MemoryStream input = new MemoryStream();
            input.Write(data, 0, data.Length);
            input.Position = 0;
           

            DeflateStream gzip = new DeflateStream(input, CompressionMode.Decompress, false);

            input.ReadByte();
            input.ReadByte();

            MemoryStream output = new MemoryStream();
            byte[] buff = new byte[64];
            int read = -1;
            read = gzip.Read(buff, 0, buff.Length);
           
            while (read > 0)
            {
                output.Write(buff, 0, read);
                read = gzip.Read(buff, 0, buff.Length);
            }
            gzip.Close();
            return output.ToArray();
        }

If you can't find anything without testing then I can upload the stream file I'm working on.
I managed to decode it with a PHP application so it seams right.

Thanks for you help.

解决方案

Post the value in data.


这篇关于DeflateStream类的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆