FPaths::GameContentDir() alternative in Unreal Engine 5

Hi all

I am taking an old project from unreal engine 4.22 to unreal engine 5. I get an error that says “‘GameContentDir’: is not a member of ‘FPaths’”. So i guess there should be an new alternative for this in ue5.

The full function im writing is:

std::string UimportExportLib::GetGameDirectoryPath()
{
	FString RelativePath = FPaths::GameContentDir();

	FString FullPath = IFileManager::Get().ConvertToAbsolutePathForExternalAppForRead(*RelativePath);
	//Log
	//UE_LOG(LogTemp, Warning, TEXT("%s"), *FullPath);

	std::string strPath(TCHAR_TO_UTF8(*FullPath));

	return strPath;
}

IMPORTANT:
I didnt write this code as i mainly work with blueprints. But the other guy who wrote this has left the project.

1 Like

Maybe
FPaths::ProjectContentDir()

It pointed to <project_dir>/Content/ for editor project
and <platform_root>/<game_name>/Content/ for packed game

1 Like

This worked like a charm.
Thank you very much.

Here is some code for console debugging :

FString directory = FPaths::ProjectContentDir();
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, directory);
//You should get a path until .../Content
1 Like