将图像加载到文件流
我正在使用加载图像
OpenFileDialog open = new OpenFileDialog();
选择文件后,“打开”中填充了多个项目,包括路径。
现在我想将文件加载到文件流(或类似的东西)中以通过网络服务发送......这可能吗?
谢谢
I am loading an image using
OpenFileDialog open = new OpenFileDialog();
After I select the file, "open" is populated with several items, including the path.
Now I would like to load the file into a filestream (or something similar) to be sent via a webservice... is this possible?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用
FileStream
打开该文件:然后,您可以将其传递到 Web 服务 http 上下文 Response .OutputStream 属性。您仍然需要设置正确的 mime 类型和各种标头,但这效果很好:
话虽如此,从 Web 服务(或 Web 应用程序)发送文件的最简单方法是使用 Response.WriteFile 方法:
You can open the file with
FileStream
:You can then pass this through to the web service http context Response.OutputStream property. You will still need to set the correct mime type and various headers, but this works well:
Having said that, the easiest way to send a file from a web service (or web app) is to use the Response.WriteFile method:
试试这个:
try this:
是的,可以创建图像
或放入流中
,但是应该发送热图像,这由您决定
sendToWs(img)
Yes it is possible to create an image
or into a stream
But hot it should be send it is up to You to decide
sendToWs(img)