In CPP
#include "RWTxtFile.h"
#include "Misc/Paths.h"
#include "Misc/FileHelper.h"
FString filePath = "E:\\myfile.txt";
FString URWTxtFile::ReadFString()
{
FString fileText = "";
FFileHelper::LoadFileToString(fileText, *filePath);
UE_LOG(LogTemp, Warning, TEXT("%s"), *fileText);
return fileText;
}
bool URWTxtFile::ReadBool(FString& result)
{
return FFileHelper::LoadFileToString(result, *filePath);
}
In .h
#include “CoreMinimal.h”
#include “Kismet/BlueprintFunctionLibrary.h”
#include “RWTxtFile.generated.h”
/**
*
*/
UCLASS()
class ONEACTION_API URWTxtFile : public UBlueprintFunctionLibrary
{
GENERATED_BODY() public:
UFUNCTION(BlueprintPure, Category = "FileRead", meta = (Keywords = "ReadTxt"))
static FString ReadFString();
UFUNCTION(BlueprintCallable, Category = "FileRead", meta = (Keywords = "ReadTxt"))
static bool ReadBool(FString& result);
};
Am I doing this wrong? No matter what I tried it is always blank and yes the file location is correct.
I tested it in both 4.22 and 4.23 and nothing works.