Packaged Game Paths, Obtain Directories Based on Executable Location

From Epic Wiki
Jump to: navigation, search


Author: Rama (talk)

Dear Community,

Here is how you get access to various parts of the directory structure of a Packaged game!

You do not need to use ConverRelativePathToFull while testing WITH_EDITOR builds, though it will still work correctly.

But it is essential to include in packaged builds!

Below are the directories that get returned for each of several different UE4 C++ FPath:: functions!

You can use pretty much any one of these to then create your own directory structure all inside of wherever your game's packaged binary is running from.

How It Works

All the other paths are found by using the BaseDir, where the exe is running from.

This is determined at runtime, so if the entire project is moved, all the paths below will still work correctly!


FString ThePath = FString(FPlatformProcess::BaseDir());

InstallDir/WindowsNoEditor/ (or other OS)

Please note this will differ based on the OS you are packaging the game for :)

FString ThePath = FPaths::ConvertRelativePathToFull(FPaths::RootDir());


FString ThePath = FPaths::ConvertRelativePathToFull(FPaths::GameDir());


FString ThePath = FPaths::ConvertRelativePathToFull(FPaths::GameContentDir());


FString ThePath = FPaths::ConvertRelativePathToFull(FPaths::GameSavedDir());


FString ThePath = FPaths::ConvertRelativePathToFull(FPaths::GameLogDir());

Sandbox File Path

When run the program in WindowsNoEditor mode. All file I/O will be saved to a Sandbox folder.

In this case, the real path on the disk is wrapped by ConvertToSandboxPath, defined in IPlatformFileSandboxWrapper.cpp. This ConvertToSandboxPath is different from FPaths::ConvertToSandboxPath.

To get the real filename on the disk. You need to call GetFilenameOnDisk to get the real filename. Notice: The file must has been written to the disk. Otherwise the GetFilenameOnDisk will only return the directory name.

IFileManager& FileManager = IFileManager::Get();
FString DiskFilename = FileManager.GetFilenameOnDisk(*FullFilename);

qiuwch (talk)

Dynamic Relocation of Project

The above code I am sharing with you will work even if you change the location of your packaged game after packaging!

Try it!

I added many many subdirectories between my InstallDir and WindowsNoEditor and it still worked perfectly!

So even if the end user moves everything starting with WindowsNoEditor around, the above code will still generate the correct and updated directory structure!


Now you know how to create your own directory structures relative to the installation directory of your packaged game!


Rama (talk)