views:

53

answers:

1

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.

+1  A: 

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.

Fredrik Mörk
The reason why is in this answer: http://stackoverflow.com/questions/2972271/c-why-does-system-io-file-getlastaccesstime-return-an-expected-value-when-the-f/2973642#2973642
Hans Passant