【问题标题】:Retrieve image stored in in db and save to a file检索存储在数据库中的图像并保存到文件
【发布时间】:2012-09-27 17:10:41
【问题描述】:

我有一个客户要求能够从 Sql Server Db 检索图像并转身并将其保存到他计算机上的目录中。他希望能够通过 asp.net 网页做到这一点。我能够从图像中检索图像作为字节数组,但不知道如何获取该图像并将其作为文件保存到目录中。有人对如何做到这一点有任何想法吗?谢谢。

【问题讨论】:

  • 你尝试了哪些选项?

标签: asp.net sql-server image


【解决方案1】:

你可以试试Save Method

    MemoryStream memoryStream = new MemoryStream((byte[])YourDataTable.Rows[0]["ImageData"]);
    Picturebox picturebox = new Picturebox();
    picturebox.Image = Image.FromStream(memoryStream);
    picturebox.Image.Save("...YourPath", System.Drawing.Imaging.ImageFormat.Jpeg)

【讨论】:

  • 谢谢。我一直在寻找什么。我最终不得不将图像保存在服务器上的临时目录中,然后显示一个浏览器另存为对话框,供用户在本地保存。
  • 我很乐意帮助你,乔治
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-01-11
相关资源
最近更新 更多