Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm using c# to get a thumbnail of an image on upload and save it in a specific folder. I've given a path name to save it currently. I need to know how to save it without using a dialog box.

What I have tried:

if (image != null)
               {
                   imgThumb = image.GetThumbnailImage(100, 100, null, new IntPtr());
                   this.Refresh();

                   imgThumb.Save("C:\\Users\\Acer\\Pictures\\Camera Roll\\thumbnail2.jpg");
                   MessageBox.Show("Image Saved Successfully");

               }
Posted
Updated 22-Aug-21 20:01pm
Comments
Er. Puneet Goel 27-Aug-18 1:04am    
Without dialog box means? are you passing folder path in the dialog box or you don't need dialog box for upload?
Member 13958707 27-Aug-18 1:45am    
To upload the image I've used an open dialog box but for save i need to know if there's any way to save the image without using the save dialog box and it could be save images in the same folder with different names.
Member 13958707 27-Aug-18 1:45am    
To upload the image I've used an open dialog box but for save i need to know if there's any way to save the image without using the save dialog box and it could be save images in the same folder with different names.
Er. Puneet Goel 27-Aug-18 1:53am    
Alright, and what is the problem with your code?
Member 13958707 27-Aug-18 2:19am    
Since i've defined a path, the image could be saved only once by the defined name in the path.

imgThumb.Save("C:\\Users\\Acer\\Pictures\\Camera Roll\\thumbnail2.jpg");

imgThumb.Save("C:\\Users\\Acer\\Pictures\\Camera Roll\\thumbnail2.jpg");


Maybe you need to change your Thumbnail2.jpg.
you are all time saving on the same file.

string strPictures = "Thumbnail" + 1;
imgThumb.Save(string.Format(@"C:\Users\Acer\Pictures\Camera Roll\{0}", strPictures));
 
Share this answer
 
Comments
Member 13958707 27-Aug-18 5:50am    
I need to generate an jpeg type of file. but this generates file type of file
Member 12993442 27-Aug-18 5:52am    
string strPictures = "Thumbnail" + 1 + ".jpg";
string strPictures = "Thumbnail" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".jpg";
imgThumb.Save(string.Format(@"C:\Users\Acer\Pictures\Camera Roll\{0}", strPictures));


This way you will have always new image name
 
Share this answer
 
Comments
Member 13958707 27-Aug-18 23:48pm    
This worked perfectly. Thank you
Er. Puneet Goel 28-Aug-18 1:51am    
welcome

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