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?

1 Like

Here:
https://answers.unrealengine.com/questions/61858/using-ffilemanagergeneric-for-listing-files-in-dir.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.

1 Like

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:

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.

3 Likes

Thanks for your post. It helped me to learn about filemannger and I solved my problem with the help of below link

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);

3 Likes