C#中的DateTime.ToFileTimeUtc()方法用于将当前DateTime对象的值转换为Windows文件时间。
以下是语法-
public long ToFileTimeUtc ();
现在让我们看一个实现DateTime.ToFileTimeUtc()方法的示例-
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.ToFileTimeUtc(); Console.WriteLine("Windows file time (Utc) = {0}", res); } }
输出结果
这将产生以下输出-
Date = 5/10/2019 6:10:25 AM Windows file time (Utc) = 132019422250000000
现在让我们来看另一个实现DateTime.ToFileTimeUtc()方法的示例-
using System; public class Demo { public static void Main() { DateTime d = DateTime.Now; Console.WriteLine("Date = {0}", d); long res = d.ToFileTimeUtc(); Console.WriteLine("Windows file time (Utc) = {0}", res); } }
输出结果
这将产生以下输出-
Date = 10/16/2019 8:25:58 AM Windows file time (Utc) = 132156879583999032