I’m trying to write a class that will need to write an array of strings to a text file and also read from that same file. I’ve done some debugging and have no idea what’s wrong with it. I tested it with a SaveStringToFile and that worked, but I need to save the array. Here is the function:
.h
FString dataPath = “testArray.txt”;
TArray currentData;
.cpp
void ALeapNeuralNet::SaveFile()
{
FString len = FString::FromInt(currentData.Num());
UE_LOG(LogTemp, Warning, TEXT("Length of data array: %s"), *len);
bool success = FFileHelper::SaveStringArrayToFile(currentData, *dataPath);
FString result = success ? ("Successful") : ("Failed");
UE_LOG(LogTemp, Warning, TEXT("Saved File: %s"), *result);
FString dir = FPaths::ProjectDir() + dataPath;
UE_LOG(LogTemp, Warning, TEXT("Saved to: %s"), *dir);
}
Output:
Length of Array: 80
Saved File: Successful
Saved to: Expected Location