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();
posted on 2010-05-31 15:02  游子  阅读(362)  评论(1编辑  收藏  举报