vs.net中打开数据库中的文件(保存/下载)
2008-05-07 15:04
253 查看
private void Download(Byte[] filedata, string sFileName)
{
HttpContext context = HttpContext.Current;
if (context != null)
{
context.Response.Clear();
context.Response.Charset = "utf-8";
context.Response.Buffer = true;
context.Response.ContentType = "application/msword";
context.Response.ContentEncoding = System.Text.Encoding.UTF8;
//下载
//context.Response.AppendHeader("Content-Disposition", "attachment;filename=" + sFileName);
context.Response.AppendHeader("Content-Disposition", "inline"); //直接打开
context.Response.BinaryWrite(filedata);
context.Response.Flush();
context.Response.Close();
context.Response.End();
}
}
其他格式文件,修改 context.Response.ContentType
{
HttpContext context = HttpContext.Current;
if (context != null)
{
context.Response.Clear();
context.Response.Charset = "utf-8";
context.Response.Buffer = true;
context.Response.ContentType = "application/msword";
context.Response.ContentEncoding = System.Text.Encoding.UTF8;
//下载
//context.Response.AppendHeader("Content-Disposition", "attachment;filename=" + sFileName);
context.Response.AppendHeader("Content-Disposition", "inline"); //直接打开
context.Response.BinaryWrite(filedata);
context.Response.Flush();
context.Response.Close();
context.Response.End();
}
}
其他格式文件,修改 context.Response.ContentType
相关文章推荐
- ASP.NET MVC文件上传下载Demo(文件保存在数据库)
- ASP.NET下载文件(弹出打开保存文件对话框)
- ASP.NET下载文件(弹出打开保存文件对话框)
- ASP.NET下载文件(弹出打开保存文件对话框)
- [转]ASP.NET下载文件(弹出打开保存文件对话框)
- python 打开sqlite3内存数据库,操作完毕将数据保存到文件数据库
- 将文件上传、下载(以二进制流保存到数据库)
- ASP.NET直接下载一个文件,而不是在IE中打开它
- 用VS.NET打开网上下载的.NET web项目出错的解决办法
- [完]PHP文件下载 下载GET值中含有中文字符的文件,保存中文文件名,文件不能打开,遇到的编码问题
- 关于创建Excel表格问题(保存至指定文件/弹出直接打开还是下载,并可以选择保存路径的对话框)
- asp.net生成csv文件,并在客户端点击下载(文件流直接输出到客户端而不是先生成保存在服务端再下载)
- 用VB.NET 如果将任何文件以二进制形式保存在数据库,然后再从数据库读取出来
- 在VS.NET内使用“从源代码管理打开”时出现无法读取项目文件的错误
- 解决vs创建或打开C++浏览数据库文件*.sdf时发生错误的问题
- ASP.NET 2.0 - 如何把上传的文件保存到数据库字段 (转自章立民CnBlogs)
- ASP.NET直接下载一个文件,而不是在IE中打开它
- Asp.net(C#)读取数据库并生成JS文件制作首页图片切换效果(附demo源码下载)
- ASP.NET中文件上传下载方法集合(上传限制,保存方式-二进制或文件形式,上传Internet上的资源 )
- 在文件下载的时候将其保存而不是直接在浏览器上打开!