Stream.Length throws NotSupportedException

前端 未结 6 1901
予麋鹿
予麋鹿 2020-12-14 15:30

I am getting a error when attempting stream.Length on a Stream object sent into my WCF method.

Unhandled Exception!
 Error ID: 0
 Error Code: Unknown
 Is War         


        
6条回答
  •  别那么骄傲
    2020-12-14 16:09

    You can't always get the length of a stream. In the case of a network stream, the only way of finding out the length is to read data from it until it's closed, for example.

    What are you trying to do? Could you read from the stream until it's exhausted, copying the data into a MemoryStream as you go?

提交回复
热议问题