问题
My client gets from another client a stream but my client need to read only from the middle of that stream.
In WCF, the stream I get, cannot be converted to FileStream even if the other client created that stream at the start as FileStream before he gave that stream to my client.
Thats why my client cant do that:
Stream1.Read(Buffer, Middle_Of_Stream, Buffer.Length)
Any solutions will be appreciated!
*streaming mode = streaming.
回答1:
The stream you get on the client cannot be converted to a file stream because it's likely bound to the network stream which was used for the transfer. A FileStream in the server cannot (and should not, for many reasons, with security being often one of them) accessed by a client, so what WCF does is read from the file stream, and copies the bytes to the network stream. On the client you get a readonly (and non-seekable) stream.
If you want to convert it to a file stream at the client side, you can create a new file (possibly on the temp directory), then save the stream you get at the proxy call to it.
来源:https://stackoverflow.com/questions/11374976/wcf-stream-changing-position