m3ntat
m3ntat

Reputation: 3683

c# file UNC path LastWriteTime not working

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.

Upvotes: 0

Views: 1687

Answers (1)

Fredrik Mörk
Fredrik Mörk

Reputation: 158289

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.

Upvotes: 2

Related Questions