piperzero 发表于 2013-1-15 22:28:11

遭遇Asp.Net长文件名下载的问题和解决办法

在Asp.Net中写了一个附件上传和下载的程序,附件上传到数据库中,然后将附件的GUID保存起来,我们可以根据GUID来找到数据库中的附件,一般附件下载的代码是:
<div class="cnblogs_code"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->privatevoidDownload(stringID)
{
file=logic.GetAttachmentByID(newGuid(ID));
Response.AddHeader("Content-Type",file.Type);
Response.AppendHeader("Content-Disposition","attachment;filename=\""+HttpUtility.UrlEncode(file.FileName)+"\"");
Response.BinaryWrite(file.Data.ToArray());
Response.End();
}
页: [1]
查看完整版本: 遭遇Asp.Net长文件名下载的问题和解决办法