获取文件移动datetime [英] Getting file move datetime

查看:160
本文介绍了获取文件移动datetime的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您复制文件(在Windows环境中)时,创建和LastAccess日期时间将被修改,并可以使用 FileInfo 对象检索。

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

但是,当文件移入文件夹时,我找不到任何可靠的datetime(直接链接到一个文件)。当文件移动时,窗口是否更新任何datetime值(可以检索)?

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.

推荐答案

所以这似乎是在Windows中如何工作:

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 RichCopy 是几个可以使用/ DCOPY:T保存目录的mtime的命令行工具切换,但这只适用于Vista和更新版本。
可以保留时间戳的另一个复制实用程序是 XXCOPY

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

您可以在本页尾部找到RoboCopy的一些示例:
http:/ /www.computerhope.com/robocopy.htm

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

这篇关于获取文件移动datetime的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆