/// <summary> /// 文件下载 /// </summary> /// <param name="filename"></param> public void DownFile(string filename) { FileInfo info = new FileInfo(Server.MapPath(filename)); Response.Clear(); Response.ClearContent(); Response.ClearHeaders(); string urlName = HttpUtility.UrlEncode(filename, System.Text.Encoding.UTF8); Response.AddHeader("Content-Disposition", "attachment;filename=" + urlName); Response.AddHeader("Content-Length", info.Length.ToString()); Response.AddHeader("Content-Transfer-Encoding", "binary"); Response.ContentType = "application/octet-stream"; Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312"); Response.WriteFile(info.FullName); Response.Flush(); Response.End(); }