WCF Stream- changing position

梦想的初衷 提交于 2019-12-23 03:10:15

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!