Why does FGenericPlatformProcess::GetCurrentWorkingDirectory( ) always return an empty string?

Hi there, you should use the FPaths class, which provides various useful methods for dealing with paths. Specifically, you can use FPaths::ProjectDir() to get the directory of the project or FPaths::ProjectContentDir() to get the content directory of the project.

Getting the Project Directory

#include "Misc/Paths.h"

FString ProjectDirectory = FPaths::ProjectDir();
UE_LOG(LogTemp, Log, TEXT("Project Directory: %s"), *ProjectDirectory);

Getting the Content Directory

#include "Misc/Paths.h"

FString ContentDirectory = FPaths::ProjectContentDir();
UE_LOG(LogTemp, Log, TEXT("Content Directory: %s"), *ContentDirectory);

Hope this helps.

1 Like