我正在尝试通过调用以下代码来设置 inflater.Position:
Stream data = Compress(buffer); // data: length=12, position=12
//inflater: length=0, position=12
InflaterInputStream inflater = new InflaterInputStream(data);
inflater.IsStreamOwner = false;
// move forward:
inflater.Dispose();
data.Position = 0;
inflater = new InflaterInputStream(data); // inflater.position=0
inflater.IsStreamOwner = false;
byte[] buff = new byte[newPos - Position];
while(newPos > Position)
int count = inflater.Read(buff, 0, buff.Length); //inflater.position=12
现在,当我尝试前进时,位置始终保持在其原始值。是因为无论我在 Read 方法中放入什么长度,该方法总是读取整个流,因此位置 = 流的结尾?我该如何设置inflater.Position?
追问:为什么inflater的长度是0?它与 CanWrite 属性为假有什么关系吗?