当前位置:编程学习 > C#/ASP.NET >>

如何从数据库中下载文件 代码如何写 本人菜鸟 望各位赐教

   用.NET  C#如何从数据库中下载文件  代码如何写  本人菜鸟 望各位赐教  在线等!! --------------------编程问答-------------------- 能说具体点吗 什么叫从数据库下载文件? --------------------编程问答--------------------
            FileInfo Fi = new FileInfo("");
            if (Fi.Exists)
            {
                FileStream fs = new FileStream(filePath, FileMode.Open);
                byte[] bytes = new byte[(int)fs.Length];
                fs.Read(bytes, 0, bytes.Length);
                fs.Close();
                Response.ContentType = "application/octet-stream";                Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(dt.Rows[0]["Name"].ToString(), System.Text.Encoding.UTF8));
                Response.BinaryWrite(bytes);
                Response.Flush();
                Response.End();
            }
Response.AppendHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(FileName), System.Text.Encoding.GetEncoding("utf-8")));
Response.ContentType = "application/octet-stream";
Response.WriteFile(Filepath);
Response.End(); --------------------编程问答--------------------
引用 1 楼 gll062 的回复:
能说具体点吗 什么叫从数据库下载文件?

就是文件先是上传到数据库中  然后在从数据库中下载到本地 [img=http://b42.photo.store.qq.com/http_imgload.cgi?/rurl4_b=4a6fca80747bc1d0b8f9b51bb5d18fd856f9786c57cf542d2635544ee13c80ea77e3ccdeff5e87522130f7fe49f94686d3f29098b4037646fdfaaa23118c57d29c5c99630d2327513ca70c640b7b8b830f315e81&a=38&b=42][/img]
补充:.NET技术 ,  C#
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,