-
July 22nd, 2013, 01:36 PM
#1
How To Get TimeStamp of a File -- File.GetCreationTime Not Working
Hi
I've searched around the net and the conventional answer for getting the timestamp of a file is to use
File.GetCreationTime. But for some reason, the return DateTime is always different than the timestamp of the file shown in Windows Exlorer.
I'd post sample code, but really, it's a one-liner with a call to File.GetCreationTime();
-
July 22nd, 2013, 08:40 PM
#2
Re: How To Get TimeStamp of a File -- File.GetCreationTime Not Working
Are you confusing the "Date Modified" with the "Date Created"?
Code:
var fileName = "c:\\formatter.log";
var dt1 = File.GetCreationTime(fileName); // Date Created
var dt2 = File.GetLastWriteTime(fileName); // Date Modified
-
July 24th, 2013, 07:53 AM
#3
Re: How To Get TimeStamp of a File -- File.GetCreationTime Not Working
Thanks, yes, that's what happened.
It would seem that the "LastWriteTime" would be a date that is later in time (more recent) than "CreationTime", but for some reason, it's backwards for me. I think it's because the files that I'm operating on are files that have been moved from another folder, and therefore, the creation time would be the time of when it was moved compared to the timestamp, which is carried over as the same timestamp of the file before before it was moved.
-
July 24th, 2013, 11:40 AM
#4
Re: How To Get TimeStamp of a File -- File.GetCreationTime Not Working
Yes, I believe you are correct. If you want, you can use the File.WriteXXX methods to adjust the creation times.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|