I need to craft a Stream
that will only support Read()
operation - the stream will be readonly and non-seekable. Still I have to implement a lot of properties such as Position
(which will throw a NotImplementedException
) - that's a lot of boilerplate code.
Is there perhaps some standard implementation for such stream where I only need to override
the Read()
operation?
CanWrite
andCanSeek
to return false.MemoryStream
allows you to create a read-only version (although it is seekable).sealed
, so you can overrideCanSeek
there :)MemoryStream
would mean that my class is a flavor ofMemoryStream
which it is really not.