Download

How to get file list in a directory?

I want to list all the file name in a directory, Is there any function available in unreal?

Here:
https://answers.unrealengine.com/questions/61858/using-ffilemanagergeneric-for-listing-files-in-dir.html

https://docs.unrealengine.com/latest/INT/API/Runtime/Core/Misc/FFileHelper/index.html

A lot of very similar questions asked there just use the search function :).

Also your question is very generic if you provide some more details maybe I can help more.

Let’s say I have more than 5 files(such as: Shape_Cone.uasset, Shape_Cube.uasset, and many more) in folder(/Game/StarterContent/Shapes/).

I’d like get the all file names and store in a FString array.

Use


FindFiles( TArray<FString>& Result, const TCHAR* InFilename, bool Files, bool Directories )

pass in

  • “*.uasset” as InFilename to filter out only .uasset files in this folder

there is a nice question about it with a possible solution for you:

https://answers.unrealengine.com/questions/188001/ifilemanager-and-ifilemanagergeneric-return-null-f.html

FindFiles is using some path it searches for it seems, you can also find a question about it there. In above question the solution is to correcnt the path.

Thanks for your post. It helped me to learn about filemannger and I solved my problem with the help of below link
https://answers.unrealengine.com/questions/212791/how-to-get-file-list-in-a-directory.html

Hi! I found some code snippet, maybe it can help you

https://docs.unrealengine.com/en-US/…ger/index.html


FString dir = FPaths::ProjectSavedDir();
FString fileExt = TEXT("sav");
IFileManager::Get().FindFiles(SaveFileNames, *dir, *fileExt);