Hi, im trying to save the pictures with the current date and time using Date.Now, but the error (The given path's format is not supported.) occurs on line 24.
It saves perfectly when i remove Date.Now, i would really want to save the pictures with the current time so that all the pics have different names.
How can this problem be solved?
It saves perfectly when i remove Date.Now, i would really want to save the pictures with the current time so that all the pics have different names.
How can this problem be solved?
vbnet Code:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim maxHeight As Integer = 0 Dim maxWidth As Integer = 0 For Each scr As Screen In Screen.AllScreens maxWidth += scr.Bounds.Width If scr.Bounds.Height > maxHeight Then maxHeight = scr.Bounds.Height Next Dim AllScreensCapture As New Bitmap(maxWidth, maxHeight, System.Drawing.Imaging.PixelFormat.Format24bppRgb) Dim screenGrab As Bitmap Dim screenSize As Size Dim g As Graphics Dim g2 As Graphics = Graphics.FromImage(AllScreensCapture) Dim a As New Point(0, 0) For Each scr As Screen In Screen.AllScreens screenSize = New Size(scr.Bounds.Width, scr.Bounds.Height) screenGrab = New Bitmap(scr.Bounds.Width, scr.Bounds.Height) g = Graphics.FromImage(screenGrab) g.CopyFromScreen(a, New Point(0, 0), screenSize) g2.DrawImage(screenGrab, a) a.X += scr.Bounds.Width Next Dim PicName = Date.Now + ".jpg" Dim Screenshot = "C:\Users\Public\Downloads\" + PicName AllScreensCapture.Save(Screenshot, System.Drawing.Imaging.ImageFormat.Jpeg) End Sub