Why does CopyTo cause an exception? The code below it works perfect and is what i thought copyto would do.
using (var mem = new MemoryStream())
{
using (var memin = new MemoryStream(v.body))
using (var comp = new BZip2InputStream(memin))
{
//comp.CopyTo(mem); //Non-negative number required (System.ArgumentOutOfRangeException)
var buf = new Byte[1024 * 4];
int len=0;
while ((len = comp.Read(buf, 0, buf.Length)) > 0)
{
mem.Write(buf, 0, len);
}
}
Its a bug in BZip2InputStream.Read(byte[] buffer, int offset, int count)
. It returns -1 rather then 0. I reported the bug
Also CopyTo checks via != 0 rather then >0 as the code in the question does.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.