How To Get File Last Updated Time Using VB.NET

This article describes how to get file last updated time.
  • 3421

File Last Updated Time

The LastWriteTime property returns the DateTime when a file was last updated or written. The following code snippet returns the last write time of a file.

Imports System.IO

Module Module1

    Sub Main()

        Dim fileName As String = "C:\Temp\MaheshTXFI.txt"

        Dim fi As New IO.FileInfo(fileName)

        Dim exists As Boolean = fi.Exists

        ' File ReadOnly ?

        Dim updatedTime As DateTime = fi.LastWriteTime

        Console.WriteLine("Last write time: {0}", updatedTime)

        Console.ReadLine()

    End Sub

End Module

Output:

last write time of file.jpg

Categories

More Articles

© 2018 DotNetHeaven. All rights reserved.