下载文件,下载下来是乱码的文件呢。不知道什么原因
下面是下载文件的代码
ExportHyper.NavigateUrl是文件的路径
FileInfo file = new FileInfo(ExportHyper.NavigateUrl);
Response.Clear();
Response.ClearHeaders();
Response.Buffer = false;
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition","attachment;filename="+HttpUtility.UrlEncode(file.Name,System.Text.Encoding.UTF8));
Response.AppendHeader("Contet-Length", file.Length.ToString());
Response.WriteFile(file.FullName);
Response.Flush();
------解决思路----------------------
Response.ContentType = "application/octet-stream";
类型错误了
应该是
Response.ContentType = "application/ms-excel";