Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting file move datetime

When you copy a file (in a windows environment), the Creation and LastAccess datetime are modified and can be retrieved with a FileInfo object.

However, I can't find any reliable datetime (directly linked to a file) that would be changed when a file is moved into a folder. Does windows update any datetime value in the file when it's moved (and can it be retrieved)?

Note I'm not in a dead end and I have many workarounds. I'm just wondering if this could be handled directly at the file level to avoid unnecessary logic.

like image 529
The_Black_Smurf Avatar asked Dec 31 '25 20:12

The_Black_Smurf


1 Answers

So this seems to be how this works in Windows:

  • Creation time: if the target file already exists, its' creation time is preserved, otherwise it is set to the current system time.
  • Last Modification time: always copied from modification time of the source file.
  • Last Access time: always set to the current system time.

RoboCopy and RichCopy are couple of command-line tools that can preserve the mtime for directories with the /DCOPY:T switch, but this only works in Vista and newer. Another copy utility which can preserve timestamps is XXCOPY

You can find some example for RoboCopy at the end of this page: http://www.computerhope.com/robocopy.htm

like image 145
AR5HAM Avatar answered Jan 03 '26 10:01

AR5HAM



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!