c#文件上传到数据库并下载大问题

alex902008 2009-01-02 11:12:49
byte[] file = null;
file = (byte[])dr["s_mailattachement"];
FileStream fs = new FileStream(sfd1.FileName, FileMode.Create,FileAccess.Write,FileShare.Read|FileShare.Write);
fs.Write(file, 0, Convert.ToInt32(file.Length));
fs.Flush();
fs.Close();

我是把文件上传到数据库中作为保存的,但是当下载来的时候,打开,里面的内容只有system.byte[],我怎么改都是这个system.byte[],请问这是什么原因呢?我是做文件上传到数据库,并从数据库中下载,保存的字段类型是image类开,请大家帮忙
...全文
84 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
数据之巅 2009-01-04
  • 打赏
  • 举报
回复
学习。。。。二进制上传到和数据库我也遇到过麻烦啊。。。。
journeydj 2009-01-04
  • 打赏
  • 举报
回复

System.IO.MemoryStream ms = new System.IO.MemoryStream(new byte[2]);
Image image=Image.FromStream(ms);
journeydj 2009-01-04
  • 打赏
  • 举报
回复
取出来是一个字节流,如果tostring的话肯定是system.byte[]这个。。。。
System.IO.MemoryStream ms = new System.IO.MemoryStream(字节数组);
Image.FromStream(ms);

111,130

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧