Saving to a specific config file (Developer settings)

UUserInterfaceSettings* Settings = GetMutableDefault<UUserInterfaceSettings>(UUserInterfaceSettings::StaticClass());

// Modify Settings

Settings->SaveConfig();

This code saves project settings to an ini file (“Saved/Config/Windows/Engine.ini”). If you modify the same section manually from the project settings (User Interface > Software cursors) for example, you will see that the settings are written to another ini file (“Config/DefaultEngine.ini”). I want to write to that same ini file. How does this work?

Bump

Won’t write anything (silent fail):

Settings->SaveConfig(CPF_Config, TEXT("DefaultEngine.ini"));
Settings->SaveConfig(CPF_Config, TEXT("RandomName.ini"));
Settings->SaveConfig(CPF_Config, TEXT("Config/DefaultEngine.ini"));

Will work:

Settings->SaveConfig(CPF_Config, *Settings->GetDefaultConfigFilename());

GetDefaultConfigFileName() returns not only a file name but it’s directory path:
“…/…/…/…/…/Unreal Projects/YourProject/Config/DefaultEngine.ini”

4 Likes