[C#] How to 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 directory. The following code snippet sets and gets the last access date and time of a directory.

string root = @"C:\Temp";
// Get and Set Last Access time
Directory.SetLastAccessTime(root, DateTime.Now);
DateTime lastAccessTime = Directory.GetLastAccessTime(root);


Xem thêm  [C#] How to delete a directory in C#

Leave a Reply

Your email address will not be published. Required fields are marked *