通过字节流来代替链接来下载小文件

通过字节流来代替链接来下载小文件:

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();

}

posted on 2008-10-31 11:38  leenshan  阅读(351)  评论(0编辑  收藏  举报