导出文件名乱码解决方案

 var downLoad = new FileInfo(Server.MapPath("~/upload/员工考勤记录.xls"));
            Response.Clear();
            Response.ClearHeaders();
            Response.Buffer = false;
            Response.ContentType = "application/octet-stream";
            var filename = string.Format("attachment;filename={0}",
                Request.Browser != null && Request.Browser.Browser.Equals("InternetExplorer")
                    ? HttpUtility.UrlEncode(downLoad.Name, Encoding.UTF8)
                    : downLoad.Name);
            Response.AppendHeader("Content-Disposition", filename);
            Response.AppendHeader("Content-Length", downLoad.Length.ToString(CultureInfo.InvariantCulture));
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.WriteFile(downLoad.FullName);
            Response.Flush();
            Response.End();

你可能感兴趣的:(解决方案)