要将指定的Windows文件时间转换为等效的本地时间,代码如下-
using System; public class Demo { public static void Main() { DateTimeOffset offset = DateTimeOffset.FromFileTime(0); Console.WriteLine("DateTimeOffset = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ",offset); } }
输出结果
这将产生以下输出-
DateTimeOffset = 01 January 1601, 12:00:00
让我们看另一个例子-
using System; public class Demo { public static void Main() { DateTimeOffset offset = DateTimeOffset.FromFileTime(200000000); Console.WriteLine("DateTimeOffset = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ",offset); } }
输出结果
这将产生以下输出-
DateTimeOffset = 01 January 1601, 12:00:20