convert string to memory stream - Memory stream is not expandable?

后端 未结 4 1598
忘掉有多难
忘掉有多难 2021-02-06 22:21

i was trying to write a string to a memory stream, but failed with the error message:

Memory stream is not expandable.

the line of code that pr

4条回答
  •  野的像风
    2021-02-06 22:53

    When you create a MemoryStream from a byte array, you essentially create a wrapper around said array. Which means the stream's buffer cannot expand once it reaches its capacity.

    However, an HttpResponse.Filter is essentially that: a filter. The documentation states:

    When you create a Stream object and set the Filter property to the Stream object, all HTTP output sent by Write passes through the filter.

    So data ends up being written to the MemoryStream. So it would help to know what you're trying to achieve with this, exactly, because a MemoryStream would not make a useful filter...

提交回复
热议问题