Hello, with reference to this thread http://www.c-sharpcorner.com/Forums/Thread/142990/,
How can i save images captured from webcam to my c:/ drive with different file names.
i have been able to capture image webcam and save it on my c:/ drive, but am having slight problems. i want each time an image is saved,it should not overwrite the old captured one already saved on my c:/ (i.e images saved will be different from previous ones left untouched with different names e.g pix1.jpg,pix2.jpg,pixs3.jpg,pix4.jpg etc).
this is the exact codes am using to capture image from webcam
https://sites.google.com/site/webcamlibrarydotnet/winfrom-and-csharp-sample-code-and-download
i modifyied the SaveImageCapture code so that it saves directly to my c:/ drive without promting the use of FileDialog box
public static void SaveImageCapture(System.Drawing.Image image)
{
image.Save("c:\\image.gif", System.Drawing.Imaging.ImageFormat.Jpeg);
}
Loading
Dipal ChoksiPosted Oct 27, 2011, 11:28 PM
http://stackoverflow.com/questions/909521/how-to-solve-this-problem-storing-values-persistenly-of-files-in-a-directory/909545#909545
HTH
Happy Coding!
Dave ChikaPosted Oct 28, 2011, 10:13 PM
Sam HobbsPosted Oct 28, 2011, 12:34 AM
Dave ChikaPosted Oct 27, 2011, 10:57 PM
image.Save("c:\\newfolder\image1.gif", System.Drawing.Imaging.ImageFormat.Jpeg);
so how do i increment each saved image on it so that a prevoiusly saved image is not overwritten by subsequent or new ones.
Suthish NairPosted Oct 27, 2011, 2:46 PM
Dave ChikaPosted Oct 27, 2011, 12:14 AM
lets the code below helps me to save a captured image to my c:\ drive with image.gif as the image name for the the first captured image
public static void SaveImageCapture(System.Drawing.Image image)
{
image.Save("c:\\image1.gif", System.Drawing.Imaging.ImageFormat.Jpeg);
} // bolded is the first saved image name
and on saving another image it should save as it image2.gif, saving another one again as image3.gif to say image5.gif etc. all the intances of the images is saved without having to overwrite the each one.
thanks for ur response.
please am just a beginner in windows programming,so a line or more codes will be highly appreciated.
Sam HobbsPosted Oct 26, 2011, 3:32 AM
Use GetDirectories Method of the DirectoryInfo class in the System.IO namespace to get a list of files in a directory, then find the filename with the highest number in it and then just use the next number. For example, if the filenames in the directory are pix1.jpg, pix2.jpg, pix3.jpg and pix4.jpg then just use pix5.jpg.