In C#, DateTime.FromFileTimeUtc reads a Windows file time (100-nanosecond steps since January 1, 1601 UTC) and returns a DateTime with Kind.Utc.
The result is the same on every computer, which makes it the safer choice than FromFileTime for stored data.
This is a static member of System.DateTime. You call it with the type name, such as DateTime.FromFileTimeUtc(...). DateTime holds a date and time of day with a Kind of Utc, Local, or Unspecified.
Add TimeSpan.TicksPerDay, TicksPerHour, and the other constants to a file time to move it, because one file-time step equals one tick.
Library declarations
C#
public static DateTime FromFileTimeUtc(long fileTime);
Parameters
Parameter
Description
fileTime
Required. A Windows file time (ticks since January 1, 1601 UTC). Must not be negative.
Return Value
Return Value
Description
DateTime
The date and time in UTC, with Kind.Utc.
C# Examples
Example 1 — The Start of File Time
Convert 0 and read the Kind.
C#
using System;
using System.Globalization;
class Program {
static void Main() {
DateTime start = DateTime.FromFileTimeUtc(0);
Console.WriteLine(start.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture));
Console.WriteLine(start.Kind);
}
}
Output
1601-01-01 00:00:00
Utc
How It Works
Zero steps. A file time of 0 means no time has passed since the starting point.
Start in 1601. The starting point is midnight on January 1, 1601 UTC.
Utc Kind. The method marks the result as UTC.
Older than Unix. The Unix epoch starts in 1970, 369 years later.
Example 2 — Move a File Time
Convert a known file time and then add one day of ticks.
C#
using System;
using System.Globalization;
class Program {
static void Main() {
long ft = 134394336000000000;
CultureInfo inv = CultureInfo.InvariantCulture;
Console.WriteLine(DateTime.FromFileTimeUtc(ft).ToString("yyyy-MM-dd HH:mm:ss", inv));
Console.WriteLine(DateTime.FromFileTimeUtc(ft + TimeSpan.TicksPerDay).ToString("yyyy-MM-dd HH:mm:ss", inv));
}
}
Output
2026-11-18 00:00:00
2026-11-19 00:00:00
How It Works
Known number.134394336000000000 is midnight UTC on November 18, 2026.
Convert. The first line prints that midnight.
One day of ticks.TimeSpan.TicksPerDay is 864,000,000,000, and file-time steps are ticks.
Next day. Adding that amount gives midnight on November 19.
Example 3 — Unix Epoch and a Bad Number
Convert the Unix epoch value and catch an invalid file time.
C#
using System;
using System.Globalization;
class Program {
static void Main() {
DateTime unix = DateTime.FromFileTimeUtc(116444736000000000);
Console.WriteLine(unix.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture));
try {
DateTime.FromFileTimeUtc(-1);
} catch (ArgumentOutOfRangeException) {
Console.WriteLine("Invalid file time");
}
}
}
Output
1970-01-01 00:00:00
Invalid file time
How It Works
Epoch constant.116444736000000000 is the file time of January 1, 1970.
Unix date. The first line shows that 1970 date at midnight UTC.
Negative number. File times before 1601 do not exist, so -1 is rejected.
Caught.ArgumentOutOfRangeException is handled and a message is printed.
Frequently Asked Questions
A DateTime in UTC for a Windows file time, with Kind set to Utc.
January 1, 1601 at 00:00:00 UTC.
116444736000000000.
It throws ArgumentOutOfRangeException.
FromFileTimeUtc, because its result does not depend on the computer time zone.