Hi
Second attempt to post an editted answer.
Hi
Example - no problem. Here are 3 variations. This is a stand alone example, and needs a new Project with default Form1 containing a ListBox1 and Buttons 1,2 and 3. Also needs a My.Settings.Counter as an Integer value - initialized to 1. Depending on your needs, the easiest one is the My.Settings.Counter one. The BaseFileName is used in all generated file names in one way or another.
' Form1 with ListBox1,
' Buttons 1, 2 1nd 3
Option Strict On
Option Explicit On
Public Class Form1
Dim BaseFileName As String = "Accounts.txt"
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim part1 As String = Now.Ticks.ToString & " " & IO.Path.GetFileName(BaseFileName)
ListBox1.Items.Add("Using TICKS")
ListBox1.Items.Add(FinalPath(part1))
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim part1 As String = IO.Path.GetFileNameWithoutExtension(BaseFileName)
Dim part2 As String = IO.Path.GetExtension(BaseFileName)
ListBox1.Items.Add("Using LARGE DATE STRING")
ListBox1.Items.Add(FinalPath(part1 & Now.ToString(" yyyy MM dd HH-mm-ss-ffff") & part2))
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
' this is probably the simplest
' assuming a My.Settings.Counter as an Integer has been created.
Dim part1 As String = IO.Path.GetFileNameWithoutExtension(BaseFileName)
Dim part2 As String = IO.Path.GetExtension(BaseFileName)
ListBox1.Items.Add("Using simple My.Settings.Counter")
ListBox1.Items.Add(FinalPath(part1 & My.Settings.Counter.ToString & part2))
' will work over application start/end
My.Settings.Counter += 1
End Sub
Function FinalPath(FinalFileName As String) As String
' make final path
Return IO.Path.Combine(Application.StartupPath, FinalFileName)
End Function
End Class