mathanraj76
Member
- Joined
- Feb 4, 2013
- Messages
- 6
- Programming Experience
- Beginner
hi
I have this code but i want i each time it save image it must have date and time at behind
for an example : Image0001_27-dec-2013,Image0002_27-dec-2013 and son..on
but with this code it save image "0000","0001","0002" and son..on
Private Function NewFileName(ByVal path As String, ByVal PrefixName As String) As String
Dim fileTime As DateTime = DateTime.Now
Dim filename As String = DateAndTime.Now.ToString
Dim dir As IO.DirectoryInfo = IO.Directory.CreateDirectory(path)
Dim num As Integer = -1
For Each f As IO.FileInfo In dir.GetFiles("*.jpg")
If f.Name.Contains(PrefixName) Then
Dim temp = f.Name.ToLower.Replace(PrefixName.ToLower, "")
temp = temp.ToLower.Replace(".jpg", "")
Dim tempnum = CInt(Val(temp))
If tempnum > num Then num = tempnum
End If
Next
Return PrefixName & (num + 1).ToString("0000_") & ".jpg"
End Function
Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click
Dim thePath = IO.Path.Combine("C:\Users\mathanraj\Desktop\image\", NewFileName("C:\Users\mathanraj\Desktop\image\", "image"))
captureImageBox.Image.Save(thePath, System.Drawing.Imaging.ImageFormat.Jpeg)
If Len(Trim(Me.lblPath.Text)) > 0 Then
If (_capture Is Nothing) Then
Try
_capture = New Emgu.CV.Capture
Catch excpt As NullReferenceException
MessageBox.Show(excpt.Message)
End Try
End If
If (Not _capture Is Nothing) Then
If _captureInProgress Then
' Me.captureButton.Text = "Start Capture"
RemoveHandler Application.Idle, New EventHandler(AddressOf Me.ProcessFrame)
'Me.captureImageBox.Image.Save(Me.lblPath.Text, ImageFormat.Jpeg)
'Me.captureImageBox.ImageLocation = Me.lblPath.Text
Else
' captureButton.Text = "Capture"
AddHandler Application.Idle, New EventHandler(AddressOf Me.ProcessFrame)
End If
_captureInProgress = Not _captureInProgress
End If
Thanks
I have this code but i want i each time it save image it must have date and time at behind
for an example : Image0001_27-dec-2013,Image0002_27-dec-2013 and son..on
but with this code it save image "0000","0001","0002" and son..on
Private Function NewFileName(ByVal path As String, ByVal PrefixName As String) As String
Dim fileTime As DateTime = DateTime.Now
Dim filename As String = DateAndTime.Now.ToString
Dim dir As IO.DirectoryInfo = IO.Directory.CreateDirectory(path)
Dim num As Integer = -1
For Each f As IO.FileInfo In dir.GetFiles("*.jpg")
If f.Name.Contains(PrefixName) Then
Dim temp = f.Name.ToLower.Replace(PrefixName.ToLower, "")
temp = temp.ToLower.Replace(".jpg", "")
Dim tempnum = CInt(Val(temp))
If tempnum > num Then num = tempnum
End If
Next
Return PrefixName & (num + 1).ToString("0000_") & ".jpg"
End Function
Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click
Dim thePath = IO.Path.Combine("C:\Users\mathanraj\Desktop\image\", NewFileName("C:\Users\mathanraj\Desktop\image\", "image"))
captureImageBox.Image.Save(thePath, System.Drawing.Imaging.ImageFormat.Jpeg)
If Len(Trim(Me.lblPath.Text)) > 0 Then
If (_capture Is Nothing) Then
Try
_capture = New Emgu.CV.Capture
Catch excpt As NullReferenceException
MessageBox.Show(excpt.Message)
End Try
End If
If (Not _capture Is Nothing) Then
If _captureInProgress Then
' Me.captureButton.Text = "Start Capture"
RemoveHandler Application.Idle, New EventHandler(AddressOf Me.ProcessFrame)
'Me.captureImageBox.Image.Save(Me.lblPath.Text, ImageFormat.Jpeg)
'Me.captureImageBox.ImageLocation = Me.lblPath.Text
Else
' captureButton.Text = "Capture"
AddHandler Application.Idle, New EventHandler(AddressOf Me.ProcessFrame)
End If
_captureInProgress = Not _captureInProgress
End If
Thanks