Reader Level:
ARTICLE

Get and Set File Last Write Time in C#

On July 20, 2012 Articles | Files, Directory, IO
In this article we will discuss about how to get and set Last Write Time of File in C#.
  • 0
  • 0
  • 4506

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";
File
.SetLastWriteTime(fileName, DateTime.Now);
DateTime
dt = File.GetLastWriteTime(fileName);
Console
.WriteLine("File last write time: {0}", dt.ToString()); 

Free Book

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

Dinesh Beniwal

 I am working as VP Content Manager, responsible for content publishing, content development, and social relation. You can follow me on twitter @dbeniwal21

  • 4rank
  • 4M readers
COMMENT USING

Trending up