Need to minus one second to file name and display - HELP!

Okay all of this is working but now I need to get button called "previous" to work. I need to minus one second to the file and then display the pictures with that change. I really have no idea how to do this.

file is broken up like this:
Cam1-20060224165650-01.jpg

Cam1     -2006   02       24         1656  50                         -01.jpg
(camera)- year month  day and military time with seconds -01.jpg

so adding it will be Cam1-200602224165651-01.jpg


Dim folder As String = "C:\Projects\Darryl\Queue Review Files\" & DateTime.ParseExact(cmbDate.SelectedItem.ToString, "MMMM d, yyyy", Nothing).ToString("M-d") & "\Cam {0}\Cam{0}" & cmbTime.Text.Substring(cmbTime.Text.IndexOf("-"))

        For i As Integer = 1 To 8

            Dim pcb As PictureBox = ApplicationControls.FindControl(Me, "pcbCam" & i)
         
            If Not pcb Is Nothing Then

                If File.Exists(String.Format(folder, i)) Then
                    pcb.Image = Image.FromFile(String.Format(folder, i))
                Else
                    pcb.Image = Image.FromFile("C:\Projects\Darryl\Queue Review Files\noimage.jpg")
                End If
            End If

        Next i
Kit_Kat111Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

armoghanCommented:
If you have the date object ..
just subtract 1 second frmo it
like

Dim oneSecondLessDate As Date = originalDate.Subtract(New TimeSpan(0, 0, 1))
0
armoghanCommented:
Overall it is like

Dim originalDateAs Date = DateTime.ParseExact("20060224165650", "yyyyMMddHHmmss", Nothing)
Dim oneSecondLessDate As Date = originalDate.Subtract(New TimeSpan(0, 0, 1))
0
Kit_Kat111Author Commented:
Actually I just want to add a 1 to the end section of the file name, not an actual date or time.


Cam1-20060224165650-01.jpg
Cam1     -2006   02       24         1656  50                         -01.jpg

Sorry for the confusion.
                                                         +1
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

xersoftCommented:
Is this what you are trying to do?

        Dim file1 As New IO.FileInfo("c:\TestFolder\Cam1-20060224165650.jpg")
        Dim File2 As New IO.FileInfo(IO.Path.Combine(IO.Path.GetDirectoryName(file1.FullName), IO.Path.GetFileNameWithoutExtension(file1.FullName) & "-01" & IO.Path.GetExtension(file1.FullName)))

        MsgBox(file1.FullName & vbCrLf & File2.FullName)
0
Bob LearnedCommented:
I believe that this is what you are after:

Imports System.Text.RegularExpressions

Public Class FileOperations

  Public Shared Function IncrementFileName(ByVal fileName As String) As String

    ' Example:  Rename Cam1-20060224165650-01.jpg to Cam1-20060224165650-02.jpg
    Dim pattern As String = "(?<file>Cam\d-\d{14}-)(?<index>\d{2})(?<ext>[A-Za-z.]+)"

    Dim match As Match = Regex.Match(fileName, pattern)

    If match.Success Then
      Dim file As String = match.Groups("file").Value
      Dim index As Integer = Val(match.Groups("index").Value)
      Dim ext As String = match.Groups("ext").Value

      fileName = file & (index + 1).ToString("00") & ext

    End If

    Return fileName

  End Function

End Class

Sample:
    MsgBox(FileOperations.IncrementFileName("Cam1-20060224165650-01.jpg"))

Bob
0
Bob LearnedCommented:
Simpler form without regular expressions:

  Private Function IncrementFileName(ByVal fileName As String, ByVal start As Integer, ByVal length As Integer) As String

    Dim builder As New System.Text.StringBuilder(fileName)
    Dim index As Integer = Val(fileName.Substring(start, length)) + 1

    builder.Remove(start, length)
    builder.Insert(start, index.ToString("00"))

    Return builder.ToString()

  End Function

Sample:
   MsgBox(IncrementFileName("Cam1-20060224165650-01.jpg", 20, 2))

Bob
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Kit_Kat111Author Commented:
Sorry I haven't forgotten about this question just have been dragged away on something unexpected. I will try your suggestion and post back tomorrow.

Thank you for your assistance with my problem, and also for your patience.
0
Kit_Kat111Author Commented:
Thank you very much!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.