IFIleManager and IFileManagerGeneric return null for files

That is it!

I changed your code a bit to call it via Blueprint.

For those who want to do this.

You have to create a “new C++ class” that inherits from “Blueprint Function Libary”.

Then you have to add the following code to the .h & the .cpp.

.h:

Add this before you #include “MyBlueprintFunctionLibrary.generated.h”.

#include "HAL/FileManagerGeneric.h"
#include "Misc/Paths.h"

Add this in the UClass definition after GENERATED_BODY() !

public:
	UFUNCTION(BlueprintCallable, Category = FileManager)
		static TArray<FString> getFilesInFolder(FString Directory, FString Extension);

.cpp:

Dont forget to use your classname instead of “UMyBlueprintFunctionLibary”!

TArray<FString> UMyBlueprintFunctionLibrary::getFilesInFolder(FString Directory, FString Extension)
{
	TArray<FString> output;
	output.Empty();
	if (FPaths::DirectoryExists(Directory))
	{
		FString path = Directory + Extension;
		FFileManagerGeneric::Get().FindFiles(output, *path, true, false);
	}
	return output;
}

Compile it and you can call it via Blueprint.


Call getFilesInFolder

1 Like