Question

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.

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top