110,539
社区成员
发帖
与我相关
我的任务
分享
//下载
public void DownLoad(string path,string filename)
{
if (System.IO.File.Exists(path))
{
FileInfo file = new FileInfo(path);
Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8"); //解决中文乱码
Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(filename)); //解决中文文件名乱码
Response.AddHeader("Content-length", file.Length.ToString());
Response.ContentType = "appliction/octet-stream";
Response.WriteFile(file.FullName);
Response.End();
}
}