How to get modified time of Directory?

I want to get the modified date of a directory on the file system. I’m using code like this:

FFileManagerGeneric fm;
FDateTime mod = fm.GetTimeStamp(tchardirectory);

but the result of GetTimeStamp is always minvalue. The documentation says this happens if you pass in something that does not exist. However I’m quite certain it exists – in debugging, I set a watch on tchardirectory, and copy+pasted its value into Explorer and it took me to a valid directory. I’ve also confirmed the directory has a valid modified time.
A closer look at the documentation suggests GetTimeStamp is only for files and not directories, but FFileManagerGeneric doesn’t appear to have a counterpart function for directories nor is there anything like FDirectoryManagerGeneric so I seem to be looking in the right place…

Old question but if someone’s looking for the answer, the code works.

I pass the Path as FString, as I was having problems with the TCHAR declaration:

void UCustomBPL::GetFileTimeStamp(FString Path, FDateTime& FileDateTime)
{
	FFileManagerGeneric fm;
	const TCHAR* Filepath = *Path;

	FileDateTime = fm.GetTimeStamp(Filepath);
}
1 Like