Link to home
Start Free TrialLog in
Avatar of SiraX
SiraXFlag for Luxembourg

asked on

Filetime to Date in C#

I've got a problem converting Filetime to Date in C#

I'm working with the Win 32 API and with the FtpFindFirstFile which return me ftCreationTime in FileData. I use this type as FileData:
      public class FileData
      {
            public long      fileAttributes = 0;
            public FILETIME ftCreationTime;
            public FILETIME      ftLastAccessTime;
            public FILETIME      ftLastWriteTime;
            public long      nFileSizeHigh = 0;
            public long      nFileSizeLow = 0;
            public long      dwReserved0 = 0;
            public long      dwReserved1 = 0;
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst=256)]
            public String      fileName = null;
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst=14)]
            public String      alternateFileName = null;
      }

This works (I think) but now I can't or I don't know how to convert this FILETIME to long (because when it would be long I could use DateTime.FromFileTime())

I already tried to use long or ulong instead of FILETIME but then it returns 0.

Thank you for your help
ASKER CERTIFIED SOLUTION
Avatar of lbertacco
lbertacco

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SiraX

ASKER

Exactly what I need =)

Thank you very much for the quick and right answer