DateTimeOffset.FromFileTime() Method in C# Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report DateTimeOffset.FromFileTime(Int64) Method is used to convert the specified Windows file time to an equivalent local time. Syntax: public static DateTimeOffset FromFileTime (long fileTime); Here, it takes a Windows file time, expressed in ticks. Return Value: This method returns an object that represents the date and time of fileTime with the offset set to the local time offset. Exception: This method will give ArgumentOutOfRangeException if filetime is less than zero or filetime is greater than DateTimeOffset.MaxValue.Ticks. Below programs illustrate the use of DateTimeOffset.FromFileTime(Int64) Method: Example 1: csharp // C# program to demonstrate the // DateTimeOffset.FromFileTime(Int64) // Method using System; using System.Globalization; class GFG { // Main Method public static void Main() { try { // converts the specified Windows file time // to an equivalent local time. // instance using FromFileTime() method DateTimeOffset value = DateTimeOffset.FromFileTime(10000); // Display the time Console.WriteLine("DateTimeOffset is {0}", value); } catch (ArgumentOutOfRangeException e) { Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } } } Output: DateTimeOffset is 01/01/1601 00:00:00 +00:00 Example 2: For ArgumentOutOfRangeException csharp // C# program to demonstrate the // DateTimeOffset.FromFileTime(Int64) // Method using System; using System.Globalization; class GFG { // Main Method public static void Main() { try { // converts the specified Windows file time // to an equivalent local time. // instance using FromFileTime() method DateTimeOffset value = DateTimeOffset.FromFileTime(-1); // Display the time Console.WriteLine("DateTimeOffset is {0}", value); } catch (ArgumentOutOfRangeException e) { Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } } } Output: Exception Thrown: System.ArgumentOutOfRangeException Reference: https://learn.microsoft.com/en-us/dotnet/api/system.datetimeoffset.fromfiletime?view=netframework-4.7.2 Comment More infoAdvertise with us Next Article DateTimeOffset.EqualsExact() Method in C# R rohitprasad3 Follow Improve Article Tags : C# CSharp-method CSharp-DateTimeOffset-Struct Similar Reads DateTime.FromFileTime() Method in C# DateTime.FromFileTime(Int64) Method is used to converts the specified Windows file time to an equivalent local time. Syntax: public static DateTime FromFileTime (long fileTime); Here, it takes a Windows file time expressed in ticks. Return Value: This method returns an object that represents the loc 2 min read DateTime.FromFileTimeUtc() Method in C# DateTime.FromFileTimeUtc(Int64) Method is used to convert the specified Windows file time to an equivalent UTC time. Syntax: public static DateTime FromFileTimeUtc (long fileTime); Here, it takes a Windows file time expressed in ticks.Return Value: This method returns an object that represents the U 2 min read DateTimeOffset.FromUnixTimeSeconds() Method in C# DateTimeOffset.FromUnixTimeSeconds(Int64) Method is used to convert a Unix time expressed as the number of seconds that have elapsed since 1970-01-01T00:00:00Z to a DateTimeOffset value. Syntax: public static DateTimeOffset FromUnixTimeSeconds (long seconds); Here, it takes a Unix time, expressed as 2 min read DateTimeOffset.FromUnixTimeMilliseconds() Method in C# DateTimeOffset.FromUnixTimeMilliseconds(Int64) Method is used to convert a Unix time expressed as the number of milliseconds which have elapsed since 1970-01-01T00:00:00Z to a DateTimeOffset value. Syntax: public static DateTimeOffset FromUnixTimeMilliseconds (long milliseconds); Here, it takes a Un 2 min read DateTimeOffset.EqualsExact() Method in C# DateTimeOffset.EqualsExact(DateTimeOffset) Method is used to determine whether the current DateTimeOffset object represents the same time and has the same offset as a specified DateTimeOffset object. Syntax: public bool EqualsExact (DateTimeOffset other); Here, it takes the object to compare to the 2 min read DateTimeOffset.GetHashCode Method in C# DateTimeOffset.GetHashCode Method is used to get the hash code for the current DateTimeOffset object. Syntax: public override int GetHashCode (); Return Value: This method returns a 32-bit signed integer hash code. Below programs illustrate the use of DateTimeOffset.GetHashCode() Method: Example 1: 2 min read Like