下载附件
来源:互联网 发布:西门子plc vb编程入门 编辑:程序博客网 时间:2024/04/28 18:53
protected void Page_Load(object sender, EventArgs e)
{
string AttachmentID = "";
try
{
AttachmentID = Request.QueryString["AttachmentID"] == null ? "" : Request.QueryString["AttachmentID"].ToString();
if ("" == AttachmentID)
{
Response.Close();
}
else
{
DataTable m_Dtl = new DataTable();
BLL_TBAbsenceAttachment attachment = new BLL_TBAbsenceAttachment();
m_Dtl = attachment.GetAttachmentByID(AttachmentID);
if (m_Dtl.Rows.Count > 0)
{
/*方法二:空格被替换成"+"了*/
string FileName = System.Web.HttpUtility.UrlEncode(System.Text.Encoding.UTF8.GetBytes(m_Dtl.Rows[0]["FileName"].ToString()));
FileName = FileName.Replace("+", " ");//空格被替换成"+"了 反替换
Response.AddHeader("Content-Disposition", "attachment; filename=" + @FileName);
Response.Charset = "gb2312";
Response.ContentType = "application/octet-stream";
Response.BinaryWrite((byte[])m_Dtl.Rows[0]["Content"]);
Response.Flush();
/*原始方法
Response.AddHeader("Content-Disposition", "attachment; filename=" + m_Dtl.Rows[0]["AttachmentName"].ToString());
Response.Charset = "gb2312";
Response.ContentType=m_Dtl.Rows[0]["AttachmentContentType"].ToString();
Response.BinaryWrite((byte[])m_Dtl.Rows[0]["AttachmentContent"]);
Response.Flush();*/
}
else
{
Response.Close();
}
}
}
catch (Exception)
{
throw new Exception();
}
}
- 下载附件
- 附件下载
- 附件下载
- 附件下载
- 附件下载
- 附件下载
- asp.net 下载附件
- asp.net 下载附件
- Grails附件下载
- 中文名附件下载
- 中文名附件下载乱码
- Struts1 action 下载附件
- JSP附件下载功能
- mastudio 下载附件
- 附件上传、下载
- DownLoad下载附件事件
- 下载远程附件php
- wcm附件下载
- 移动 PC 的数据加密工具包 - 安全分析
- 笔记本35个基础问题解答
- 动态上传多附件!!
- 未来计算机
- Intel 笔记本CPU型号 透析
- 下载附件
- 如何用JAVA调用存储过程
- MySQL连接8小时未使用连接失效的处理方法
- 触发器ORA-01403: no data found的解决方法
- 配置svn+apache2.0
- 高质量C++成员函数的重载、覆盖与隐藏
- IE 下的打印
- Axis2中文手册
- 批处理语法