【问题标题】:Using File.SetCreationTime and File.SetLastWriteTime makes Windows Explorer hide these details for the file使用 File.SetCreationTime 和 File.SetLastWriteTime 使 Windows 资源管理器隐藏文件的这些详细信息
【发布时间】:2021-09-09 22:31:40
【问题描述】:

我在尝试对文件设置 CreationTime 和 LastWriteTime 时遇到了一些奇怪的事情。

DateTime nDT = new DateTime(1974, 12, 23,10,31,34);
string path = @"C:\Users\matte\Desktop\Desktop_Test.zip";
File.SetCreationTime(path, nDT);
File.SetLastWriteTime(path, nDT);

我在控制台应用程序中使用此代码,当它运行时,它会更新这些属性,但相关值会从 Windows 资源管理器中消失。

我有错吗?

【问题讨论】:

  • 如果您打开文件的属性,您应该会看到按预期显示的日期。也许这些日期在 Windows 诞生之前与文件资源管理器未在列表中显示它的原因有关
  • 1/1/1980 是一个标记值,但它应该只是那个确切的日期。我记得在那个特定日期(以及之前的某个日期)遇到了这个问题,事实上我相信在使用确切日期时会抛出异常。无论如何devblogs.microsoft.com/oldnewthing/20161108-00/?p=94665 但显然你的价值在那之前

标签: c# windows file datetime explorer


【解决方案1】:

如果日期在 1980 年 1 月 1 日之前,我想你不会看到它。文章太多但对我来说有意义的是https://superuser.com/questions/796762/what-is-the-range-of-dates-that-windows-explorer-can-display

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-07
    • 1970-01-01
    • 2011-04-15
    • 1970-01-01
    相关资源
    最近更新 更多