Directory AccessTime, WriteTime, and CreationTime for nonexistent directories inconsistent
Labeld in code as "//See VSWhidbey # 92050"
On Windows, Directory.GetAccessTime, Directory.GetWriteTime, and Directory.GetCreationTime (as well as their DirectoryInfo clones) will return default values when queried with a path to a nonexistent directory.
On Unix, running those same methods for AccessTime and WriteTime throws a "FileNotFoundException".
Is this behavioral difference desired?
Example:
Assert.Equal(DateTime.FromFileTime(0).Ticks, Directory.GetLastAccessTime("doesntexist").Ticks); //true on Windows, throws on Ubuntu
Assert.Equal(DateTime.FromFileTime(0).Ticks, Directory.GetLastWriteTime("doesntexist").Ticks); //same as above
This is the same as https://github.com/dotnet/corefx/issues/1728, right?
Essentially yes, but with Directory/DirectoryInfo instead of File/FileInfo.
Design review feedback leaned towards allowing Unix to have a different behavior than Windows because of the Windows-specific notions of FromFileTime, though it wasn't entirely conclusive. Changing the Windows behavior is not what we want to do because of the breaking change it would cause, so the best option is different behaviors on different systems.
Returning the windows 0 time on a Unix machine wouldn't make any sense and returning the Unix 0 time would still be inconsistent with the Windows 0 time, so the better alternative of throwing an exception is chosen.