所有答案都在这里找到:在托管流管道组件中实现搜索方法
事实证明,在没有 Position 属性的时候。所以获取流指针当前位置的方法是调用Seek( 0, SeekOrigin.Current );
迷人。又是旧事新事。
该页面提供了所需的 Seek 实现:
override public long Seek(long offset, SeekOrigin origin)
{
long pos = -1;
switch(origin)
{
case SeekOrigin.Begin :
pos = offset;
break;
case SeekOrigin.Current :
pos = Position + offset;
break;
case SeekOrigin.End :
break;
}
// We generally disallow seeking of the stream
// However, in unmanaged code, many people use Seek(0,CURR) to retrieve // the current position
// Special case (that is, if Seek does not change position, do not
// throw an exception)
if (pos==Position)
{
return pos;
}
else
{
throw new NotSupportedException("ForwardOnlyEventingReadStream does not support Seek()");
}
}
这就是整个解决方案。耶!