Exception with new GZipStream

Apr 3, 2009 at 5:50 PM
Edited Apr 3, 2009 at 5:50 PM
I'm attempting to use GZipStream to decompress a gzip file.   I have version 1.8.2.7 of the library.  Below is a snippet of the code I'm using. Basically, the first time I read from the GZipStream, an Ionic.Zlib.ZlibException is thrown. The exception itself has the message: "Can't handle this! AvailableBytesIn=8187". Any ideas what may cause this?   I introduced the use of the BufferedStream, thinking it may help with the problem, but no such luck.

Thanks
Steve


string outputFile;
string inputFile;

FileInfo info = new FileInfo(inputFile);
byte[] working = new byte[info.Length];
using (Stream inputStream= new BufferedStream(File.OpenRead(inputFile), (int)info.Length))
{
using (GZipStream decompressor = new GZipStream(inputStream, CompressionMode.Decompress))
{
int n = decompressor.Read(working, 0, working.Length);

if (File.Exists(outputFile))
File.Delete(outputFile);

using (Stream output = File.Create(outputFile))
{
output.Write(working, 0, n);
while (n != 0)
{
n = decompressor.Read(working, 0, working.Length);
output.Write(working, 0, n);
}
}
}
}