要将当前DateTime对象的值转换为Windows文件时间,代码如下-
using System; public class Demo { public static void Main() { DateTime d = DateTime.Now; Console.WriteLine("Date = {0}", d); long res = d.ToFileTime(); Console.WriteLine("Windows file time = {0}", res); } }
输出结果
这将产生以下输出-
Date = 10/16/2019 8:17:26 AM Windows file time = 132156874462559390
让我们看另一个例子-
using System; public class Demo { public static void Main() { DateTime d = new DateTime(2019, 05, 10, 6, 10, 25); Console.WriteLine("Date = {0}", d); long res = d.ToFileTime(); Console.WriteLine("Windows file time = {0}", res); } }
输出结果
这将产生以下输出-
Date = 5/10/2019 6:10:25 AM Windows file time = 132019422250000000