FileInfo.LastWriteTime如何早于FileInfo.CreationTime? [英] How can FileInfo.LastWriteTime be earlier than FileInfo.CreationTime?

查看:106
本文介绍了FileInfo.LastWriteTime如何早于FileInfo.CreationTime?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我今天正在调试一些代码,发现我的FileInfo对象之一的LastWriteTime早于其CreationTime时间.这可能/预期吗?

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.

也就是说,最可能的解释是文件是从一个地方复制到另一个地方的.创建时间将是复制发生的时间.修改时间将是源文件的最后修改时间,即复制之前的时间.因此,当文件被复制时,修改时间也被复制.要看到这种情况,只需在您的计算机上选择一个文件即可.创建它的副本(CTRL + C,CTRL + V)并查看副本的属性.

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.

这篇关于FileInfo.LastWriteTime如何早于FileInfo.CreationTime?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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