开发者

c# file UNC path LastWriteTime not working

开发者 https://www.devze.com 2023-01-15 16:53 出处:网络
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 shar开发者_运维技巧e using a UNC path I get \"01/01/1601 00

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 shar开发者_运维技巧e 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消