将检索到的图像保存在本地驱动器中 [英] Save retrieved Image in Local Drive

查看:94
本文介绍了将检索到的图像保存在本地驱动器中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..
现在我能够从fileuploader上传图像并将其以字节为单位保存在数据库中(图像列数据类型为Image).我也检索了存储的图像并使用Image控件将其显示在我的应用程序中.
现在我的问题是我需要将检索到的图像保存在本地驱动器中.谁能帮我解决这个问题?

Hi..
Now i am able to upload image from fileuploader and save it in database in bytes(image column datatype is Image).Also i retrieved that stored image and displayed it in my application using Image control.
Now my problem i need to save the retrieved image in local drive. Can anyone help me to solve this problem

推荐答案

如果只有Microsoft提供了Image类,并且它具有Save方法,:rolleyes::rolleyes:

http://msdn.microsoft.com/en-us/library/ktx83wah.aspx [ ^ ]
If only Microsoft would have provided an Image class and it had a Save method :rolleyes: :rolleyes:

http://msdn.microsoft.com/en-us/library/ktx83wah.aspx[^]


要将图像保存到本地驱动器,可以使用给定命令
将IO命名空间导入为
To save image to local drive you can use given command
import IO namespace as
using System.IO;


然后使用给定的代码


and then use given code

SaveFileDialog obj = new SaveFileDialog();
          obj.Filter = "JPeg Image|*.jpg|Bitmap Image|*.bmp|Gif Image|*.gif";
          obj.Title = "Save your Image File";
          obj.ShowDialog();
          if (obj.FileName != "")
         {
             FileStream fs = (FileStream)obj.OpenFile();
             switch (obj.FilterIndex)
             {
                 case 1 : this.pictureBox1.Image.Save(fs, System.Drawing.Imaging.ImageFormat.Jpeg);
                     break;
                 case 2 : this.pictureBox1.Image.Save(fs, System.Drawing.Imaging.ImageFormat.Bmp);
                     break;
                 case 3 : this.pictureBox1.Image.Save(fs, System.Drawing.Imaging.ImageFormat.Gif);
                     break;
             } fs.Close();
         }


这篇关于将检索到的图像保存在本地驱动器中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆