ITPub博客

首页 > Linux操作系统 > Linux操作系统 > C#文件下载

C#文件下载

原创 Linux操作系统 作者:iDotNetSpace 时间:2010-05-31 15:21:34 0 删除 编辑
string filepath = Server.MapPath("~/public/file.txt"); 
        FileInfo fi = new FileInfo(filepath);
        Response.Clear();
        Response.AddHeader("Content-Disposition", "attachment; filename=" + fi.Name);
        Response.AddHeader("Content-Length", fi.Length.ToString());
        Response.ContentType = "application/octet-stream";
        Response.Filter.Close();
        Response.WriteFile(fi.FullName);
        Response.End();

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/12639172/viewspace-664086/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-01-04

  • 博文量
    2376
  • 访问量
    5766563