开发者

Is there a constant describing the minimal Windows FileTime Value in .Net?

开发者 https://www.devze.com 2022-12-18 07:50 出处:网络
I am using the DateTime.ToFileTime and Fro开发者_运维技巧mFileTime methods to store and retrieve timestamps in a database. The mininum windows file time is midnight, Jan 1, 1601. Is there a constant s

I am using the DateTime.ToFileTime and Fro开发者_运维技巧mFileTime methods to store and retrieve timestamps in a database. The mininum windows file time is midnight, Jan 1, 1601. Is there a constant similar to DateTime.MinValue, that describes this value?


No, but it is simple to create your own:

    public static readonly DateTime MinFileTime = DateTime.FromFileTimeUtc(0);


For people like me searching for the same "min file value" for a DateTimeOffset, the definition would be:

public static readonly DateTimeOffset MinFileTimeOffset = new DateTimeOffset(MinFileTime);

with MinFileTime defined as in Hans' answer..

PS: DateTimeOffset doesn't have a FromFileTimeUtc method.

0

精彩评论

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