System.IO.File using: .SetCreationTime, .GetCreationTime, .SetLastAccessTime, .GetLastAccessTime, .SetLastWriteTime & .GetLastWriteTime
Private Sub SetAndGetFileTimesDemo()
     Dim FileName As String
     Dim dt1, dt2, dt3, dta, dtb, dtc As DateTime
     Dim sdx1 As String
     ' Create some arbitratry but specific dates 
     dt1 = New DateTime(2017, 4, 19, 15, 27, 30) ' 3:27:30 PM
     dt2 = New DateTime(2017, 4, 19, 15, 28, 30) ' 3:28:30 PM
     dt3 = New DateTime(2017, 4, 19, 15, 29, 30) ' 3:29:30 PM
     ' creates both the name and file of zero length
     FileName = System.IO.Path.GetTempFileName
     sdx1 = String.Format("Temp file name = {0}", FileName)
     Console.WriteLine(sdx1)
     IO.File.SetCreationTime(FileName, dt1)
     IO.File.SetLastAccessTime(FileName, dt2)
     IO.File.SetLastWriteTime(FileName, dt3)
     dta = IO.File.GetCreationTime(FileName)
     dtb = IO.File.GetLastAccessTime(FileName)
     dtc = IO.File.GetLastWriteTime(FileName)
     sdx1 = String.Format("Creation time = {0}",dta) 
     Console.WriteLine(sdx1)
     sdx1 = String.Format("Last access time = {0}",dtb)
     Console.WriteLine(sdx1) 
    |sdx1 = String.Format(" Last write time = {0}", dtc)
     Console.WriteLine(sdx1)
 End Sub
Output:

Temp file name = C:\Users\John\AppData\Local\Temp\tmpBBE2.tmp
Creation time = 4/19/2017 3:27:30 PM 
Last access time = 4/19/2017 3:28:30 PM 
Last write time = 4/19/2017 3:29:30 PM

Each time this code is executed, a new and. different file name will be returned from Path.GetTempFileName

































































































600

1200

1800

2400

3000

3600

4200

4800

5400

6000

6600

7200

7800

8400

9000

9600

10200

10800

11400

12000

12600

13200

13800

14400

15000

15600

16200

16800

17400

18000

18600

19200

19800

20400

11/24/2015
TheLonelyProgrammer.Net
Alone in a sea of non-programmers
Home File Copy Path List Drives List Files Special Folders Accessing and changing file times