最好使用aspx页面写:
protected void Page_Load(object sender,EventArgs e)
{
if(!IsPostBack)
{
System.Io.FileStream myFileStream = new System.Io.FileStream(Server.MapPath("",System.Io.FileMode.Open));
long FileSize;
FileSize = myFileStream.Length;
byte[] Buffer = new byte[(int)FileSize];
myFileStream.Read(Buffer,,(int)myFileStream.Length);
myFileStream.Close(); Response.Clear();
Response.ClearHeaders();
Response.Content();
Response.ContentType = "image/png";
Response.AddHeader("content-disposition","attachment:filename="+"文件名.png",System.Text.Encoding.UTF8)
Response.BinaryWrite(Buffer );
}
}