.NET File.GetLastAccessTime更新文件的上次访问时间 [英] .Net File.GetLastAccessTime updates Last Access Time of file

查看:185
本文介绍了.NET File.GetLastAccessTime更新文件的上次访问时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用以下行来获得最后访问日期和文件的时间。

We are using below line to get Last access date and time of the file.

DateTime dtLastAccesstime = File.GetLastAccessTime(sFilePath);



但是,我们正面临着奇怪的问题,上述自称修改上次访问时间。所以有效的,我们正在当前的时间,最后访问时间

But we are facing strange problem, the above call itself modifies the Last access time. So effectively we are getting current time as last access time.

推荐答案

您可能会发现的这个帖子有用的,特别是:

You may find this post useful, in particular:

在Windows Vista中,的维持上次访问时间默认情况下禁用

Starting in Windows Vista, maintaining the last-access time is disabled by default.

这意味着,现在大多数操作系统都将无法维持上次访问时间(我想可能占你所看到的奇怪行为)。

Which means that nowadays most operating systems won't maintain the last access time (which I suppose could account for the odd behaviour you are seeing).

即使这不是的情况下这篇文章重点介绍了一些在许多情况下,由此上次访问时间可能已更新,当你不是故意的 - 你可以确保你的应用程序不执行任何其他文件的访问

Even if this is not the case this post highlights some of the many scenarios whereby the last access time could have been updated when you didn't mean to - can you be sure that your application doesn't perform any other file access?

这篇关于.NET File.GetLastAccessTime更新文件的上次访问时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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