/// <summary> /// 文件下载 /// </summary> /// <param>文件名</param> /// <param>文件全名</param> /// <param>Response</param> public static void savefile(string savename,string FullFileName,System.Web.HttpResponse Response) { try { FileInfo DownloadFile = new FileInfo(FullFileName); if (DownloadFile.Exists) { Response.Clear(); Response.ClearHeaders(); Response.Buffer = false; Response.ContentType = "application/octet-stream"; Response.AppendHeader("Content-Disposition", "attachment;filename="+ System.Web.HttpUtility.UrlEncode(savename,System.Text.Encoding.UTF8)); Response.AppendHeader("Content-Length", DownloadFile.Length.ToString()); Response.WriteFile(DownloadFile.FullName); Response.Flush(); Response.End(); } else { //文件不存在 } } catch { //文件不存在 } }
(编辑:焦作站长网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|