文件下载方法

来源:互联网 发布:数据流程图的绘制方法 编辑:程序博客网 时间:2024/06/11 07:44

private void FileDownload(string FullFileName)
{
    FileInfo DownloadFile = new FileInfo(FullFileName);
    Response.Clear();
    Response.ClearHeaders();
    Response.Buffer=false;
    Response.ContentType="application/octet-stream";
    Response.AppendHeader("Content-Disposition","attachment;filename=" +HttpUtility.UrlEncode(DownloadFile.FullName,System.Text.Encoding.UTF8));
    Response.AppendHeader("Content-Length",DownloadFile.Length.ToString());
    Response.WriteFile(DownloadFile.FullName);
    Response.Flush();
    Response.End();
}

原创粉丝点击