How to modify a file time in VB.NET

1 Answer

0 votes
Imports System.IO

Module Module1

    Sub Main()

        Try

            Dim file As New IO.FileInfo("d:\\data.txt")

            Console.WriteLine(file.LastWriteTime())

            Dim d As DateTime = file.LastWriteTime

            file.LastWriteTime = New DateTime(d.Year, d.Month, d.Day, 12, 0, 0)

            Console.WriteLine(file.LastWriteTime())

        Catch ex As Exception

            Console.WriteLine(ex.Message)

        End Try

    End Sub

    'run:
    ' 
    '12/31/1999 3:40:05 AM
    '12/31/1999 12:00:00 PM

End Module

 



answered Jun 16, 2015 by avibootz

Related questions

...