Get and Set File Last Write Time in C#

The SetLastWriteTime and GetLastWriteTime methods are used to set and get the last write date and time of the specified file. The following code snippet sets and gets the last write date and time of a file.

// Get and set file last write time

string fileName = @"c:\temp\Mahesh.txt";
.SetLastWriteTime(fileName, DateTime.Now);
dt = File.GetLastWriteTime(fileName);
.WriteLine("File last write time: {0}", dt.ToString()); 

Free Book

Download Complete free book here: Working with Directories in C#

Up Next
    Ebook Download
    View all
    View all