Hello everyone , I am new to these forms so please bear with me.
I have a project in VB2010 , I have a button which takes a screenshot and then saves it on the hard disk somewhere. I want it so that if the file exists it will increment new file names instead of overwriting the file. How do I do this ? I have this code on button click:
I have a project in VB2010 , I have a button which takes a screenshot and then saves it on the hard disk somewhere. I want it so that if the file exists it will increment new file names instead of overwriting the file. How do I do this ? I have this code on button click:
Code:
Dim bounds As Rectangle
Dim screenshot As System.Drawing.Bitmap
Dim graph As Graphics
bounds = Screen.PrimaryScreen.Bounds
screenshot = New System.Drawing.Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
graph = Graphics.FromImage(screenshot)
graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
PictureBox1.Image = screenshot
PictureBox1.Image.Save(My.Settings.ssdirectory 'user specified directory & "\Screenshot.jpg", System.Drawing.Imaging.ImageFormat.Bmp)