C# ASPX.NET 文件(图片)下载

最好使用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 );
}
}
上一篇:课程回顾-Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization


下一篇:SRM 583 Div II Level Three:GameOnABoard,Dijkstra最短路径算法