下载

protected void dFile(string name)
        {
            string path = Server.MapPath("~") + name;
            //初始化 FileInfo 类的实例,它作为文件路径的包装
            FileInfo fi = new FileInfo(path);
            
            Response.Clear();
            Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(fi.Name));
            //Response.AddHeader("Content-Length", fi.Length.ToString());
            Response.ContentType = "application/octet-stream";
            Response.Filter.Close();
            Response.WriteFile(fi.FullName);
            Response.End();
        }      

posted @ 2013-04-02 11:54  王者杂货铺  阅读(104)  评论(0编辑  收藏  举报