@msdn=http://search.microsoft.com/search/results.aspx?qu=$$$ @pinvoke=http://pinvoke.net/$$$.htm Summary: The DosDateTimeToFileTime API !!!!C# Signature: [DllImport("kernel32.dll")] static extern bool DosDateTimeToFileTime(ushort wFatDate, ushort wFatTime, out UFILETIME lpFileTime); !!!!User-Defined Types: public struct UFILETIME { public uint dwLowDateTime; public uint dwHighDateTime; } !!!!Notes: Sample and signature code originally used System.Runtime.InteropServices.FILETIME, but this uses ints instead of uints (DWORDs) meaning that this line: long hFT2 = (((long) ft.dwHighDateTime) << 32) + ft.dwLowDateTime; gave incorrect results due to signs. !!!!Tips & Tricks: Please add some! Alternate C# process: [DllImport("kernel32", CallingConvention = CallingConvention.StdCall, SetLastError = true)] private static extern int DosDateTimeToFileTime(ushort dateValue, ushort timeValue, out UInt64 fileTime); [DllImport("kernel32", CallingConvention = CallingConvention.StdCall, SetLastError = true)] private static extern int FileTimeToDosDateTime(ref UInt64 fileTimeInfo, out ushort dateValue, out ushort TimeValue); void Test() { UInt64 data = Convert.ToUInt64(DateTime.Now.ToFileTime()); int result = 0; ushort dateValue = 0; ushort timeValue = 0; result = FileTimeToDosDateTime(ref data, out dateValue, out timeValue); data = 0; result = DosDateTimeToFileTime(dateValue, timeValue, out data); Console.Write(DateTime.FromFileTime(Convert.ToInt64(data)).ToString("MM/dd/yyyy hh:mm:ss tt")); } !!!!Sample Code: public struct UFILETIME { public uint dwLowDateTime; public uint dwHighDateTime; } private static DateTime ConvertDosDateTime(ushort DosDate, ushort DosTime) { UFILETIME filetime = new UFILETIME(); DosDateTimeToFileTime(DosDate, DosTime, out filetime); //Reference: http://www.aspemporium.com/howto.aspx?hid=26 long longfiletime = (long)(((ulong)filetime.dwHighDateTime << 32) + (ulong)filetime.dwLowDateTime); return DateTime.FromFileTimeUtc(longfiletime); } !!!!Alternative Managed API: Do you know one? Please contribute it! Documentation: DosDateTimeToFileTime@msdn on MSDN
Edit kernel32.dosdatet...
You do not have permission to change this page. If you feel this is in error, please send feedback with the contact link on the main page.