/// <summary>
/// 下载文件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btn_FileExport_Click(object sender, EventArgs e)
{
Lw.Mle modelfile = Getl(FileId, "De");
if (modelfile == null || modelfile.FileContent == null || modelfile.FileContent.Length == 0)
{
MessageBox.Show(this, "文件不存在");
return;
}
byte[] productbye = modelfile.FileContent;
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=" + modelfile.FileName);
Response.AddHeader("content-length", productbye.Length.ToString());//文件大小
Response.ContentType = "application/vnd.ms-excel";
Response.ContentEncoding = System.Text.Encoding.Default;
Response.BinaryWrite(productbye);
Response.End();
Response.Close();
}
下载二进制文件
最新推荐文章于 2023-08-15 10:29:31 发布