批量备份硬盘而不修改访问时间C#

发布于 2024-08-31 20:32:53 字数 236 浏览 9 评论 0原文

我正在尝试编写一个简单的程序来备份我的闪存驱动器。我希望它在后台自动、安静地工作,而且我也希望它尽可能快。问题是,重置所有访问时间对我来说毫无用处,也是我想避免的事情。我知道我可以读取访问时间并将其设置回来,但我打赌将来有一天它会失败。在不更改文件的情况下读取文件会简单得多。 另外,最快的方法是什么?例如,闪存驱动器和外部硬盘驱动器之间有什么区别?

我用 C# 编写此内容,因为这是最简单的方法,并且它可能会持续使用更多代 Windows。

I'm trying to write a simple program that will backup my flash drive. I want it to work automatically and silently in the background, and I also want it to be as quick as possible. The thing is, resetting all the access times is useless to me, and something I want to avoid. I know I can read the access times and set them back, but I bet it will fail one day in the future. It would be much simpler to read the files without ever changing it.
Also, what is the fastest way to do this? What differences would there be between, say, a flash drive and an external hard drive.

I am writing this in C#, as it is the simplest way to do it and it will probably last more generations of Windows..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

愁杀 2024-09-07 20:32:53

这不是一个合乎逻辑的假设。 FileInfo.LastAccessTime 属性在 .NET 规范中被冻结,它肯定比 C# 代码更耐用。如果某个 Windows 版本由于某种神秘原因不支持文件上的上次访问时间戳,那么 Microsoft 将有责任以合理的方式重新实现该属性。属性的语义也被冻结了,并且在过去的 17 年里,永远不会有一个 Windows 版本允许您从文件中读取但不能更新值。

顺便说一句,您还应该重置 FileAttributes.Archive 位。

That's not a logical assumption. The FileInfo.LastAccessTime property is frozen in the .NET specification, it is sure to outlast your C# code. If there will ever be a version of Windows that for some mysterious reason doesn't support a last-accessed time stamp on a file then it will be Microsoft's burden to re-implement the property in a reasonable way. The semantics of the property are frozen too, and have been for the past 17 years, there will never be a version of Windows that lets you read from a file but not update the value.

Btw, you should also reset the FileAttributes.Archive bit.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文