C#  数据库中有下载文件名称     怎么在网页中加入文件下载   代码怎么写啊

解决方案 »

  1.   

               string fileName = "";
                string filePath = Server.MapPath("");//路径
                FileInfo fileInfo = new FileInfo(filePath);
                Response.Clear();
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName);
                Response.AddHeader("Content-Length", fileInfo.Length.ToString());
                Response.AddHeader("Content-Transfer-Encoding", "binary");
                Response.ContentType = "application/octet-stream";
                Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
                Response.WriteFile(fileInfo.FullName);
                Response.Flush();
                Response.End();
      

  2.   

    简单的,用<a>标签也行,直接链接到文件