Get and Set File Last Write Time Using VB.NET

In this article I describe how to get and set the last write time of file in VB.Net.
  • 4721

Get and Set File Last Write Time

The SetLastWriteTime and GetLastWriteTime methods are used to set and get the last write date and time of the specified file. The following code snippet sets and gets the last write date and time of a file.

Imports System.IO

Module Module1

    Sub Main()

        ' Get and set file last write time

        Dim fileName As String = "c:\temp\Mahesh.txt"

        File.SetLastWriteTime(fileName, DateTime.Now)

        Dim dt As DateTime = File.GetLastWriteTime(fileName)

        Console.WriteLine("File last write time: {0}", dt.ToString())

        Console.ReadLine()

    End Sub

End Module

Output:

File write time in vb.jpg

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.