Get and Set File Last Access Time Using VB.NET
In this article I describe how to get and set the last access time of file in VB.Net.
Get and Set File Last Access Time
The SetLastAccessTime and GetLastAccessTime methods are used to set and get the
last access date and time of the specified file. The following code snippet sets
and gets the last access date and time of a file.
Imports
System.IO
Module
Module1
Sub Main()
' Get and set file last access time
Dim fileName As
String =
"c:\temp\Mahesh.txt"
File.SetLastAccessTime(fileName,
DateTime.Now)
Dim dt As
DateTime = File.GetLastAccessTime(fileName)
Console.WriteLine("File
last access time: {0}", dt.ToString())
Console.ReadLine()
End Sub
End
Module
Output:
