My program receiving file time in ulong
format and I have to convert it to DateTime
format. So here is the function I wrote.
public static DateTime fileTimeToDateTime(ulong fileTime)
{
long temp = (long)fileTime;
DateTime dt1 = DateTime.FromFileTime(temp);
return dt1;
}
But for the filetime 2213360000
,function returns 1/1/1601 12:00:00 AM
but the correct should be 4/22/2009 3:28:29 PM
So then I used this webpage to convert filetime to human readable time and it gives me the correct value. So it looks something wrong with my function. Then I convert the correct date using this code peace.
string windowsTime = "4/22/2009 3:28:29 PM";
DateTime time = DateTime.Parse(windowsTime);
long ft = time.ToFileTime();
So here output ft
is 128848589090000000
and it not the filetime that I got (2213360000
). So looks something wrong with the way I think. Any idea?