What do I have to do to implement my own stream, which uses custom compression routine, similiar to, for example, GZipStream
?
我显然不得不将<代码>Stream类别分类,但我应当执行哪些方法,哪些方法可以留待执行?
基本上说来,文件有特殊部分,,但可能有一个更好和更容易的选择?
执行机构的说明
When implementing a derived class of Stream, you must provide implementations for the Read and Write methods. The asynchronous methods BeginRead, EndRead, BeginWrite, and EndWrite are implemented through the synchronous methods Read and Write. Similarly, your implementations of Read and Write will work correctly with the asynchronous methods. The default implementations of ReadByte and WriteByte create a new single-element byte array, and then call your implementations of Read and Write. When deriving from Stream, if you have an internal byte buffer, it is strongly recommended that you override these methods to access your internal buffer for substantially better performance. You must also provide implementations of CanRead, CanSeek, CanWrite, Flush, Length, Position, Seek, and SetLength.
Do not override the Close method, instead, put all of the Stream cleanup logic in the Dispose method. For more information, see Implementing a Dispose Method.