1
Vote

CrcCalculatorStream does not support seek/position

description

Is it possible to change this class to support Seek/set the Position property? It seems that this class was intentionally designed not to support it, not sure why.
This is what I am trying to do. I have wave files stored into a zip file. I want to read those files into a stream (without having to write them on disk) and using the codeplex NAudio utility play them from memory. However when I use the ZipEntry.OpenReader() method it returns a CrcCalculatorStream when I pass this stream into the NAudio utility uses the Stram.Postion to read through the stream, that is when I get the exception of "Method not supported" from The Position property.
 
    /// <summary>
    ///   The getter for this property returns the total bytes read.
    ///   If you use the setter, it will throw
    /// <see cref="NotSupportedException"/>.
    /// </summary>
    public override long Position
    {
        get { return _Crc32.TotalBytesRead; }
        set { throw new NotSupportedException(); }
    }

comments

sunahe wrote Nov 21, 2012 at 4:50 PM

Wherever CrcCalculatorStream will support seeking or not, it should be consistent about its behaviour and return correct value of its CanSeek property. If the stream always throws when trying to Seek, CanSeek should always return false. Please fix that.

sunahe wrote Nov 22, 2012 at 8:36 AM

My last comment seems to be outdated, CanSeek works in version 1.9.1.8