在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
/// <summary> /// 文件下载 /// </summary> /// <param name="FileName">文件名</param> /// <param name="FilePath">路径</param> public void BigFileDownload(string FileName, string FilePath) { try { //以字符流的形式下载文件 FileStream fs = new FileStream(filepath, FileMode.Open); byte[] bytes = new byte[(int)fs.Length]; fs.Read(bytes, 0, bytes.Length); fs.Close(); Response.ContentType = "application/octet-stream;charset=gb2321"; //通知浏览器下载文件而不是打开;对中文名称进行编码 Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(FileName, System.Text.Encoding.UTF8)); Response.BinaryWrite(bytes); Response.Flush(); Response.End(); } catch (Exception ex) { } finally { Response.Flush(); Response.End(); } }
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论