Desktop Functions:

   Smart Device Functions:

Show Recent Changes
Subscribe (RSS)
Misc. Pages
Helpful Tools
Suggested Reading
Website TODO List
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy
FileTimeToSystemTime (kernel32)

C# Signature:

static extern bool FileTimeToSystemTime([In] ref FILETIME lpFileTime,
   out SYSTEMTIME lpSystemTime);

VB.Net Signature

<DllImport( _
       "kernel32.dll", _
       CharSet:=CharSet.Auto, _
       SetLastError:=True)> _
   Friend Shared Function FileTimeToSystemTime( _
                        <[In]()> ByRef lpFileTime As FILETIME, _
                        <Out()> ByRef lpSystemTime As SYSTEMTIME) _
               As Boolean
   End Function

User-Defined Types:

FileTime and SystemTime.


By setting the SetLastError property to true, a System.ComponentModel.Win32Exception will generated if the function fails.

Tips & Tricks:

For .NET Compact Framework:

this function is contained in "coredll.dll" not "kernel32.dll"

Sample Code:

If you are trying to parse the Modified (e.g. B0D37BF53EBEC501B5) value in the URL (Shortcut) file you could use the following code:

References used for the code below:

FileTime page


    public static DateTime FileTimeToSystemTime(string hexTS) {
        string lowDT = string.Format("{0}{1}{2}{3}",
            hexTS.Substring(6, 2), hexTS.Substring(4, 2), hexTS.Substring(2, 2), hexTS.Substring(0, 2));

        string highDT = string.Format("{0}{1}{2}{3}",
            hexTS.Substring(14, 2), hexTS.Substring(12, 2), hexTS.Substring(10, 2), hexTS.Substring(8, 2));

        FILETIME fileTime;
        fileTime.dwHighDateTime = int.Parse(highDT, System.Globalization.NumberStyles.HexNumber);
        fileTime.dwLowDateTime = int.Parse(lowDT, System.Globalization.NumberStyles.HexNumber);
        long hFT2 = (((long)fileTime.dwHighDateTime) << 32) | ((uint)fileTime.dwLowDateTime);
        return DateTime.FromFileTimeUtc(hFT2);

Alternative Managed API:

You really do not need to use this function as you could use the FromFileTime or FromFileTimeUtc on DateTime class. Refer to the sample code provided in the FileTime page.


Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

Access directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version