Stream wrapper to make Stream seekable?

后端 未结 5 777
一整个雨季
一整个雨季 2020-12-05 10:37

I have a readonly System.IO.Stream implementation that is not seekable (and its Position always returns 0). I need to send it to a consumer that do

5条回答
  •  天命终不由人
    2020-12-05 11:14

    I just use the MakeStreamSeekable method from the Amazon SDK:


    MakeStreamSeekable Method (input)

    Converts a non-seekable stream into a System.IO.MemoryStream. A MemoryStream's position can be moved arbitrarily.

    Declaration Syntax

    C#

    public static Stream MakeStreamSeekable(
        Stream input
    )
    

    Parameters

    *input* ([Stream][2]) The stream to be converted

    Return Value

    A seekable MemoryStream

    Remarks

    MemoryStreams use byte arrays as their backing store. Please use this judicially as it is likely that a very large stream will cause system resources to be used up.

提交回复
热议问题