MVC资源下载-创新互联
{
//string filePath = Server.MapPath("File/") + Session["file"].ToString();//要下载的资源在本机
创新互联专注于网站设计、成都网站制作、网页设计、网站制作、网站开发。公司秉持“客户至上,用心服务”的宗旨,从客户的利益和观点出发,让客户在网络营销中找到自己的驻足之地。尊重和关怀每一位客户,用严谨的态度对待客户,用专业的服务创造价值,成为客户值得信赖的朋友,为客户解除后顾之忧。string filePath =@"\192.168.1.90wwwrootimg.cn-school.comimages667027ee9425480e8881fd923158317d.png";//要下载的资源在某个服务器
FileStream fs = new FileStream(filePath, FileMode.Open);
byte[] bytes = new byte[(int)fs.Length];
fs.Read(bytes, 0, bytes.Length);
fs.Close();
Response.Charset = "UTF-8";
Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
Response.BinaryWrite(bytes);
Response.Flush();
Response.End();
return new EmptyResult();
}
分享文章:MVC资源下载-创新互联
浏览地址:http://scyanting.com/article/ihsjp.html