To convert the specified Windows file time to an equivalent local time, the code is as follows −
Example
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);
}
}Output
This will produce the following output −
DateTimeOffset = 01 January 1601, 12:00:00
Example
Let us see another example −
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);
}
}Output
This will produce the following output −
DateTimeOffset = 01 January 1601, 12:00:20