Shipping build won't create .ini file in GameDir()

I’m trying to create a file in the root game folder in Android, but when I package it as shipping, it doesn’t create the file. I’ve also set up the permissions to WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE. If I’m packaging as Development build it creates the file. So what DO I do?

This is the code that I’m using:

//FString ThePath = FString(FPlatformProcess::BaseDir());
IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile();

FString SaveDirectory = FPaths::GameDir();
FString FileName = FString("Feydom.ini");
FString TextToSave = FString("Test");
FString AbsoluteFilePath = SaveDirectory + "/" + FileName;

// CreateDirectoryTree returns true if the destination
// directory existed prior to call or has been created
// during the call.
if (PlatformFile.CreateDirectoryTree(*SaveDirectory))
{
    bool Success = FFileHelper::SaveStringToFile(TextToSave, *AbsoluteFilePath);
    if (Success)
    {
        UE_LOG(LogTemp, Display, TEXT("Success creating and writing to file at path %s"), *AbsoluteFilePath);
        return true;
    }
    else
    {
        UE_LOG(LogTemp, Error, TEXT("Failure creating and writing to file at path %s"), *AbsoluteFilePath);
        return false;
    }
}
else
{
    UE_LOG(LogTemp, Error, TEXT("Cant't create directory at path %s "), *AbsoluteFilePath);
    return false;
}

Use FAndroidMisc::GamePersistentDownloadDir() instead of FPaths::GameDir().

Great! Thank you, this is exactly what I needed :slight_smile: