How can I get the location of the Current Project?

The path in C++ for file I/O operations seems to default to the location of the Unreal Engine Editor (UE4Editor.exe). Is there an easy way to get the path to the current project, which may differ between computers? I need to be able to do this so that files are easily shared among team members through revisioning software such as git.

1 Like

FPaths::GetProjectFilePath() returns path to project’s .uproject file. Hope this helps.

1 Like

FPaths::GameContentDir() returns the path to the Content directory of your project. There are other helper functions in FPaths to return a variety of locations should this not be suitable for your needs.

1 Like

How do I then convert the returned FString to a wchar_t*?

FString stores its characters as TCHAR, which is a type you’re not supposed to make size assumptions about (but is wchar_t by default on Windows).

Do you need wchar_t*? We have built in functionality to convert an FString to either an ANSI or UTF8 encoded char*.

TCHAR_TO_ANSI
TCHAR_TO_UTF8

I ended up just using FPlatformMisc::GameDir() and that worked fine.

1 Like