最好使用aspx页面写:

 1 protected void Page_Load(object sender,EventArgs e)
 2 {
 3      if(!IsPostBack)
 4     {
 5         System.Io.FileStream myFileStream = new System.Io.FileStream(Server.MapPath("",System.Io.FileMode.Open));
 6         long FileSize;
 7         FileSize = myFileStream.Length;
 8      byte[] Buffer = new byte[(int)FileSize];
 9         myFileStream.Read(Buffer,0,(int)myFileStream.Length);
10         myFileStream.Close();
11 
12         Response.Clear();
13         Response.ClearHeaders();
14         Response.Content();
15         Response.ContentType = "image/png";
16         Response.AddHeader("content-disposition","attachment:filename="+"文件名.png",System.Text.Encoding.UTF8)
17         Response.BinaryWrite(Buffer );
18     }  
19 }    

 

相关文章:

  • 2021-07-08
  • 2021-07-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-10
  • 2021-07-08
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
  • 2021-05-23
  • 2021-07-05
  • 2021-09-26
  • 2021-12-14
相关资源
相似解决方案