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);