DateTime.FromFileTime() Method in C#


The DateTime.FromFileTime() method in C# is used to convert the specified Windows file time to an equivalent local time.

Syntax

Following is the syntax −

public static DateTime FromFileTime (long fileTime);

Above, the parameter lifetime is a Windows file time expressed in ticks.

Example

Let us now see an example to implement the DateTime.FromFileTime() method −

using System;
public class Demo {
   public static void Main() {
      DateTime d1 = DateTime.FromFileTime(100000000000);
      System.Console.WriteLine("DateTime = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ",d1);
   }
}

Output

This will produce the following output −

DateTime = 01 January 1601, 02:46:40

Example

Let us now see another example to implement the DateTime.FromFileTime() method −

using System;
public class Demo {
   public static void Main() {
      DateTime d1 = DateTime.FromFileTime(0);
      System.Console.WriteLine("DateTime = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ",d1);
   }
}

Output

This will produce the following output −

DateTime = 01 January 1601, 12:00:00

Updated on: 07-Nov-2019

103 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements