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

string root = @"C:\Temp";
// Get and Set Last Write time
Directory.SetLastWriteTime(root, DateTime.Now);
DateTime lastWriteTime = Directory.GetLastWriteTime(root);
Console.WriteLine(lastWriteTime);

 

 

Xem thêm  [C#] How to Replace a File in C#

Leave a Reply

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