Problem with DeflateStream class

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Jan 2009
Posts: 7
Reputation: nattsurf123 is an unknown quantity at this point 
Solved Threads: 0
nattsurf123 nattsurf123 is offline Offline
Newbie Poster

Problem with DeflateStream class

 
0
  #1
Mar 25th, 2009
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC