File.SetLastAccessTime Method
Sets the date and time the specified file was last accessed.
Namespace: System.IONamespace: System.IO
Assembly: mscorlib (in mscorlib.dll)
Parameters
- path
- Type: System.String
The file for which to set the access date and time information.
- lastAccessTime
- Type: System.DateTime
A DateTime containing the value to set for the last access date and time of path. This value is expressed checks the file system for the specified file, creating it if necessary, and then sets and gets the last access time.
using System; using System.IO; class Test { public static void Main() { try { string path = @"c:\Temp\MyTest.txt"; if (!File.Exists(path)) { File.Create(path); // Update the last access time. } writing to the specified file..