文件下载
用aspx读取文件输出它
string strFile = "e:\\test.doc";
FileStream fs = new FileStream(strFile, FileMode.Open);
byte[] bytes = new byte[(int)fs.Length];
fs.Read(bytes, 0, bytes.Length);
fs.Close();
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment;filename=" & strFile);
Response.BinaryWrite(bytes);
Response.End();
用aspx读取文件输出它
string strFile = "e:\\test.doc";
FileStream fs = new FileStream(strFile, FileMode.Open);
byte[] bytes = new byte[(int)fs.Length];
fs.Read(bytes, 0, bytes.Length);
fs.Close();
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment;filename=" & strFile);
Response.BinaryWrite(bytes);
Response.End();
解决方案 »
- 关于IIS配置虚拟目录由IHttpHandler监控问题!
- gridview的数据不显示
- vs2005 如何在listbox 内嵌 checkbox
- 初学!服务器上刚安装了vs2008,建了一个gridview网页,远程看不到,出错。请看信息。
- TreeView 中 CheckBox 根据子符串勾选对应的副选框
- |M| 为什么我在Global中Server.GetLastError();而在页面中就为Null
- 如何在跳转到其它页面前清空某个Session的值?
- 高分求教!怎样将数据库中的数据添加到treeview中?
- 高分求救:通过代码设置iframe的src属性,为什么不会加载设置的url页面
- 打印问题。
- C#下这个数组的写法对不对?
- 请问在Vs.net中开发asp.net的页面时如何插入flash?急,谢谢!
string filePath="C:\temp"+"/"+scFileName;;
Response.AppendHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(scFileName,System.Text.Encoding.UTF8));
Response.WriteFile(filePath);
Response.End();
Response.ClearContent();
Response.Clear();
//文件流输出
Response.AppendHeader("Content-Disposition", "attachment;filename=" + strDisplayname);
Response.ContentType = "application/octet-stream";
this.Response.Charset = "UTF-8";
this.Response.ContentEncoding =System.Text.Encoding.Default;
Response.BinaryWrite(DocBuffer);
//结束文件流输出
Response.End();