ASP.NET 文件下载方法

时间:2010-8-30  |   0  |  标签:,
    /// 
    /// 从服务器下载文件
    /// 
    /// 文件地址
    private void DownloadFile(string FileUri)
    {
        FileInfo fi = new FileInfo(FileUri);
        Response.Clear();
        Response.ClearHeaders();
        Response.Buffer = false;
        Response.ContentType = "application/octet-stream";
        Response.AppendHeader("Content-Disposition", "attachment;filename="
			 + HttpUtility.UrlEncode(fi.FullName, System.Text.Encoding.UTF8));
        Response.AppendHeader("Content-Length", fi.Length.ToString());
        Response.WriteFile(fi.FullName);
        Response.Flush();
        Response.End();
    }

其中地址为绝对路径。





无觅相关文章插件,快速提升流量