Possible Duplicate:
How to get Modified date from file in c#
How do you, Read created / last modified time-stamp of a file, using C#?
Access timestamp (atime): which indicates the last time a file was accessed. Modified timestamp (mtime): which is the last time a file’s contents were modified. Change timestamp (ctime): which refers to the last time some metadata related to the file was changed.
Modified timestamp (mtime) indicates the last time the contents of a file were modified. For example, if new contents were added, deleted, or replaced in a file, the modified timestamp is changed. To view the modified timestamp, we can simple use the ls command with -l option. Syntax: ls -l [filename]
We will use getctime () and getmtime () function found inside path module in the os library, for getting the creation and modification times of the file. Both the above function return time in seconds since EPOCH (00:00:00 UTC on 1 January 1970) (time is of float datatype).
Modified timestamp (mtime): which is the last time a file’s contents were modified. Change timestamp (ctime): which refers to the last time some metadata related to the file was changed. In Linux, a timestamp is actually stored as a number of seconds instead of a date and time.
From: http://www.csharp-examples.net/file-creation-modification-time/
// local times
DateTime creationTime = File.GetCreationTime(@"c:\file.txt");
DateTime lastWriteTime = File.GetLastWriteTime(@"c:\file.txt");
DateTime lastAccessTime = File.GetLastAccessTime(@"c:\file.txt");
// UTC times
DateTime creationTimeUtc = File.GetCreationTimeUtc(@"c:\file.txt");
DateTime lastWriteTimeUtc = File.GetLastWriteTimeUtc(@"c:\file.txt");
DateTime lastAccessTimeUtc = File.GetLastAccessTimeUtc(@"c:\file.txt");
// write file last modification time (local / UTC)
Console.WriteLine(lastWriteTime); // 9/30/2007 2:16:04 PM
Console.WriteLine(lastWriteTimeUtc); // 9/30/2007 6:16:04 PM
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With