I'm having real trouble trying to use the .bz2 stuff from the SharpZipLib library and I've not been able to find any help else where.
Any help or advice would be much appreciated and if anyone can point me at an existing solution I can learn from that would be fantastic!
Below is what I'm trying to do, but obviously it's not working. Currently the problem I'm having is an 'EndOfStreamException' being unhandled on the marked line. The code is a bit of a mess, I've never tried to do anything like this before...
As you can probably tell I'm downloading this from the web before decompressing it, I'm fairly sure that part of the code works correctly though.
while ((inputByte = responseStream.ReadByte()) != -1)
{
using (MemoryStream ms = new MemoryStream())
{
using (BinaryWriter writer = new BinaryWriter(ms))
{
writer.Write((byte)inputByte);
}
using (BZip2InputStream unzip = new BZip2InputStream(ms)) //Exception occurs here
{
buffer = new byte[unzip.Length];
unzip.Read(buffer, 0, buffer.Length);
}
using (FileStream fs = new FileStream(fPath, FileMode.OpenOrCreate, FileAccess.Write))
{
fs.Write(buffer, 0, buffer.Length);
}
}
}