一、首先获取文件夹的相对路径
FString str(FPaths::GameContentDir() + "DataDriven/Npc/");
const TCHAR* DefaultPath = str.GetCharArray().GetData();
二、调用FindFiles函数查找该目录下的所有文件名
IFileManager& MyFileManager = IFileManager::Get();
if (MyFileManager.DirectoryExists(DefaultPath))
{
TArray<FString> AssetName;
NpcFileManager.FindFiles(AssetName, DefaultPath);
}
扩展:1)若指定第三个参数,还可进行文件类型筛选。如:*.uasset
2)可使用FindFilesRecursively函数,递归查找子文件夹中的文件。