我在尝试使用SharpZipLib库中的.bz2内容时遇到了麻烦,我无法在其他地方找到任何帮助.
任何帮助或建议将不胜感激,如果有人能指出我现有的解决方案,我可以从中学到这将是太棒了!
以下是我正在尝试做的事情,但显然它不起作用.目前我遇到的问题是在标记的行上未处理'EndOfStreamException'.代码有点混乱,我从来没有尝试过这样的事情......
正如你可以告诉我在解压缩之前从网上下载这个,我很确定部分代码可以正常工作.
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);
}
}
}
Run Code Online (Sandbox Code Playgroud)