Currently I’m trying to save to and load from a json file in my game’s root directory, e.g. savefiles/save.json. The following code should load a json file:
FString saveFilePath = FPaths::ConvertRelativePathToFull(FPaths::GameDir());
saveFilePath += "savefiles/save.json";
FString jsonString;
FFileHelper::LoadFileToString(jsonString, *saveFilePath);
TSharedPtr<FJsonObject> jsonObject;
TSharedRef< TJsonReader<> > Reader = TJsonReaderFactory<>::Create(jsonString);
if (FJsonSerializer::Deserialize(Reader, jsonObject))
{
// ...
}
When debugging the above Code I see this path being passed to LoadFileToString: L"C:/Users/[myname]/Desktop/[mygame]/savefiles/save.json". However the program actually loads files from C:/Users/[myname]/Desktop/[mygame]/Saved/Cooked/WindowsNoEditor/[mygame]/savefiles/save.json. Both files exist, since the corresponding save routine created the file in Saved/Cooked/WindowsNoEditor, and because I manually created it one in the top level. How do I fix LoadFileToString so it looks only in the directory I specified?