string strFile = Server.MapPath("/images/526763.pdf"); using (FileStream fs = new FileStream(strFile, FileMode.Open)) { byte[] bytes = new byte[(int)fs.Length]; fs.Read(bytes, 0, bytes.Length); fs.Close(); Response.ContentType = "application/octet-stream"; Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode("base.pdf", System.Text.Encoding.UTF8)); Response.BinaryWrite(bytes); Response.Flush(); Response.End(); }
将文件以流的形式另存为下载
猜你喜欢
转载自www.cnblogs.com/zhangwj/p/9945578.html
今日推荐
周排行