图像加载对FILESTREAM [英] Loading Image to Filestream

查看:177
本文介绍了图像加载对FILESTREAM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用

OpenFileDialog open = new OpenFileDialog();



我选择文件后,打开填充了几个项目,包括路径。

After I select the file, "open" is populated with several items, including the path.

现在我想将文件加载到FILESTREAM(或类似的东西)通过web服务发送...这是可能的吗?

Now I would like to load the file into a filestream (or something similar) to be sent via a webservice... is this possible?

感谢

推荐答案

您可以打开的 的FileStream

You can open the file with FileStream:

FileStream file = new FileStream("path to file", FileMode.Open);

您可以再通过对Web服务的HTTP上下文的 Response.OutputStream 财产。您仍需要设置正确的MIME类型和各种头,但这种效果很好:

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:

HttpContext.Current.Response.OutputStream = file;



说了这么多,最简单的方法来发送从Web服务(或Web应用程序)的文件是使用 Response.WriteFile 方式:

Response.WriteFile("Path To File");

这篇关于图像加载对FILESTREAM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆