I was debugging some code today and noticed one of my FileInfo
objects had its LastWriteTime
earlier than its CreationTime
time. Is this possible/expected?
These properties of the file can be modified to take any value. So there's absolutely nothing to stop this happening.
That said, the most likely explanation is that the file was copied from one place to another. The creation time will be the time the copy took place. The modification time will be the time the source file was last modified, i.e. before the copy. So, when the file is copied, the modification time is also copied. To see this happen, simply pick a file on your machine. Create a copy of it (CTRL+C, CTRL+V) and look at the properties of the copy.
In other words, it is actually not a contradiction for the creation time to be later than the modification time. The creation time is when this file object was created. The modification time is when the file contents were modified.
Sure its possible, just copy some file and past it in the same folder, you will see the dates are different:
Of course it's possible. Creation and modification time of a file are just metadata and can be changed by anyone who feels like it.
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