标签:encode 编码 chm port 分享 char 附件 fir ext
protected void btnExportErrorInfo_Click(object sender, EventArgs e)
{
string strFileName = "错误信息";
string ExportFileName = string.Empty;
HttpContext curContext = HttpContext.Current;
if (!string.IsNullOrEmpty(strFileName)) { ExportFileName = strFileName; }
//火狐浏览器文件名中文显示
if (curContext.Request.UserAgent.Contains("Firefox"))
{
ExportFileName = ExportFileName + ".txt";
}
else
{
ExportFileName = HttpUtility.UrlEncode(ExportFileName + ".txt", Encoding.UTF8);
}
// 设置编码和附件格式
curContext.Response.ContentType = "application/octet-stream";
curContext.Response.ContentEncoding = Encoding.UTF8;
curContext.Response.Charset = "";
curContext.Response.AppendHeader("Content-Disposition",
"attachment;filename=" + ExportFileName);
string ErrorInfo = "博客园是一个面向开发者的知识分享社区。自创建以来,博客园一直致力并专注于为开发者打造一个纯净的技术交流社区,推动并帮助开发者通过互联网分享知识!";
byte[] data = System.Text.Encoding.Default.GetBytes(ErrorInfo);
curContext.Response.BinaryWrite(data);
curContext.Response.End();
Dispose();
}
标签:encode 编码 chm port 分享 char 附件 fir ext
原文地址:https://www.cnblogs.com/Let-Fly/p/9402449.html