private void Download(Byte[] filedata, string sFileName)
{
HttpContext context = HttpContext.Current;
if (context != null)
{
context.Response.Clear();
context.Response.Charset = "utf-8";
context.Response.Buffer = true;
context.Response.ContentType = "application/msword";
context.Response.ContentEncoding = System.Text.Encoding.UTF8;
//下载
//context.Response.AppendHeader("Content-Disposition", "attachment;filename=" + sFileName);
context.Response.AppendHeader("Content-Disposition", "inline"); //直接打开
context.Response.BinaryWrite(filedata);
context.Response.Flush();
context.Response.Close();
context.Response.End();
}
}
其他格式文件,修改 context.Response.ContentType