设置头部,直接下载文件

 

string dir = SysSetting.WaveFileDir;
string fullPath = string.Format("{0}/{1}", dir, WebFileUtil.GetFilePathByName(fileName));
string fullPathUrl = string.Format("{0}/{1}", 
SysSetting.WaveFileUrl, WebFileUtil.GetFilePathByName(fileName));
Response.ContentType = "application/octet-stream"; 
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fullPathUrl, Encoding.UTF8));
Response.TransmitFile(fullPath);
Response.End();
 

 

你可能感兴趣的:(下载文件)