通过字节流来代替链接来下载小文件
通过字节流来代替链接来下载小文件:
if (System.IO.File.Exists(DownLoadFileName))
{
string strName=System.IO.Path.GetFileName(DownLoadFileName);
//clear Response
Response.Clear();
//设置
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "attachment;filename=" + strName);
//传输
Response.TransmitFile(DownLoadFileName);
//关闭
Response.Flush();
Response.Close();
}