您的位置:首页 > 产品设计 > UI/UE

DicomIoException: Requested 132 bytes past end of fixed length stream.

2015-07-07 22:36 453 查看
今天在用DicomFile.Open(Stream s)这个接口时,遇到一个异常: DicomIoException: Requested 132 bytes past end of fixed length stream.
具体原因我们看下源码就很清楚:public bool Require(uint count, ByteSourceCallback callback, object state) {lock (_lock) {if ((_stream.Length - _stream.Position) >= count)return true;
throw new DicomIoException("Requested {0} bytes past end of fixed length stream.", count);}}
当时的Stream的Position位于流末尾,即Length-Position等于0, 因此抛出这个异常。

解决办法很简单:首先把Stream定位到DICOM的起始位置。

类似代码如下: var stream = new MemoryStream(); using (var f = File.Open(@"1.2.156.112605.75006881735343.1369658682.4.4.1.dcm", FileMode.Open)) { f.CopyTo(stream); } stream.Seek(0, SeekOrigin.Begin); var df = Dicom.DicomFile.Open(stream);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: