Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27199

VS 2010 Increment the filename if file already exists [Resolved]

$
0
0
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:

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)


Viewing all articles
Browse latest Browse all 27199

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>