I'm wondering, how can I get a folder's creation date as a TDateTime?
FileAge() does not work with folders, only files, so sadly datetime := FileDateToDateTime(FileAge()) won't work for me.
Any help would be greatly appreciated as I am a bit stumped here.
The version of
FileAge()you are calling is deprecated (the compiler should be warning you about that). You should be using the newer overload that has aTDateTimeoutput parameter:For example:
In any case, both versions of
FileAge()use the Win32GetFileAttributesEx()and/orFindFirstFile()APIs internally, which both work just fine with folders, it is just thatFileAge()filters the output to ignore folders.So, just use those Win32 APIs directly instead. Or, you can use the RTL's
FileGetDateTimeInfo()function instead:TDateTimeInfoRechas aCreationTimeproperty of typeTDateTime.For example: