Question

File.GetLastWriteTime(pathname).ToString();

The line above works perfectly for a local file on my c: drive, if I try to a file on a network share using a UNC path I get "01/01/1601 00:00:00"

Any ideas how to resolve? my app needs to work of UNC paths.

Was it helpful?

Solution

Verify that the file name you use is correct. According to the documentation:

If the file described in the path parameter does not exist, this method returns 12:00 midnight, January 1, 1601 A.D. (C.E.) Coordinated Universal Time (UTC), adjusted to local time.

I personally find it a bit odd that the method does not instead throw a FileNotFoundException.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top