943,857 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 1247
  • C# RSS
Mar 25th, 2009
0

Problem with DeflateStream class

Expand Post »
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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nattsurf123 is offline Offline
7 posts
since Jan 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Regexp whitespace problem
Next Thread in C# Forum Timeline: C# - How do you pass a common type between 2 web services





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC