Click here to Skip to main content
15,894,720 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
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
Posted

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[^]
 
Share this answer
 
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();
         }
 
Share this answer
 
v2
Comments
[no name] 24-Dec-10 0:41am    
Read the OP's question. The image is coming from a database not from a dialog or from a picturebox. Your answer is useless and misleading.
RaviRanjanKr 24-Dec-10 0:53am    
Oh! I have just taking this question to save image from Imagecontrol to harddisk.
its my fault, thanks for inform me..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900