C# -Why does System.IO.File.GetLastAccessTime return an expected value when the file is not found?

后端 未结 6 1720
野性不改
野性不改 2021-01-04 06:05

Please, explain your thoughts.

1.  DateTime dt = System.IO.File.GetLastAccessTime(\"C:\\\\There_is_no_such_file.txt\");
2.  DateTime dt = System.IO.File.Get         


        
6条回答
  •  一向
    一向 (楼主)
    2021-01-04 06:51

    If you ask the question "When was the last time, the file "There_is_no_such_file.txt" was accessed?", you could either answer "There is no such file" or "never".

    Obviously, the team that designed the IO library opted for the second answer, with never being represented as DateTime.MinValue.

提交回复
热议问题