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

[RESOLVED] Problem with saving an image

$
0
0
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?
vbnet Code:
  1. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  2.         Dim maxHeight As Integer = 0
  3.         Dim maxWidth As Integer = 0
  4.         For Each scr As Screen In Screen.AllScreens
  5.             maxWidth += scr.Bounds.Width
  6.             If scr.Bounds.Height > maxHeight Then maxHeight = scr.Bounds.Height
  7.         Next
  8.         Dim AllScreensCapture As New Bitmap(maxWidth, maxHeight, System.Drawing.Imaging.PixelFormat.Format24bppRgb)
  9.         Dim screenGrab As Bitmap
  10.         Dim screenSize As Size
  11.         Dim g As Graphics
  12.         Dim g2 As Graphics = Graphics.FromImage(AllScreensCapture)
  13.         Dim a As New Point(0, 0)
  14.         For Each scr As Screen In Screen.AllScreens
  15.             screenSize = New Size(scr.Bounds.Width, scr.Bounds.Height)
  16.             screenGrab = New Bitmap(scr.Bounds.Width, scr.Bounds.Height)
  17.             g = Graphics.FromImage(screenGrab)
  18.             g.CopyFromScreen(a, New Point(0, 0), screenSize)
  19.             g2.DrawImage(screenGrab, a)
  20.             a.X += scr.Bounds.Width
  21.         Next
  22.         Dim PicName = Date.Now + ".jpg"
  23.         Dim Screenshot = "C:\Users\Public\Downloads\" + PicName
  24.         AllScreensCapture.Save(Screenshot, System.Drawing.Imaging.ImageFormat.Jpeg)
  25.     End Sub

Viewing all articles
Browse latest Browse all 27329

Trending Articles



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