HOME > .NET Framework > Forum > การ Format Path เกี่ยวกับการบันทึกรูป เกิด error ค่ะ มันแจ้งว่า The given path's at is not supported. ที่บรรทัด Me.PictureBox1.Image.Save
การ Format Path เกี่ยวกับการบันทึกรูป เกิด error ค่ะ มันแจ้งว่า The given path's at is not supported. ที่บรรทัด Me.PictureBox1.Image.Save
Imports System.DateTime
Imports System
Imports System.IO
Imports System.IO.DirectoryInfo
Public Class Form2
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)
Public Function SaveScreen(ByVal theFile As String) As Boolean
Dim data As IDataObject
data = Clipboard.GetDataObject()
Dim bmap As Bitmap
If data.GetDataPresent(GetType(System.Drawing.Bitmap)) Then
bmap = CType(data.GetData(GetType(System.Drawing.Bitmap)), Bitmap)
Me.PictureBox1.Image = bmap
Me.PictureBox1.Image.Save(theFile, Imaging.ImageFormat.Jpeg)
End If
End Function
Private Sub Command2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Command2.Click
Hide() 'เมื่อคลิกปุ่มจะทำการซ่อนหน้าจอนี้
Dim fname2 As String
fname2 = System.DateTime.Now.ToLongDateString
Dim fname1 As String
fname1 = System.DateTime.Now.ToLongTimeString 'System.DateTime.Now.ToLongTimeString
Dim di As DirectoryInfo = New DirectoryInfo("c:\" + fname2)
Public Function GiveMeDateTimeFormatForFileNameNow(ByVal varDateTime As DateTime _
,Optional varSeparator As String = "_")
Dim retStr As String = String.Empty
retStr = string.Format( "{1}{0}{2}{0}{3} {4}{0}{5}{0}{6}" ,varSeparator _
,varDateTime.Year.ToString() ,varDateTime.Month.ToString() ,varDateTime.Day.ToString() _
,varDateTime.Hour.ToString() ,varDateTime.Minute.ToString() ,varDateTime.Second.ToString())
Return retStr
End Function
.....
.....
Dim di As DirectoryInfo = New DirectoryInfo("c:\" + GiveMeDateTimeFormatForFileNameNow (DateTime.Now))