Absolute paths dont work?

I have a very annoying problem with file paths. If I use a full valid pathname to my project, reading files/assets are ok. But when I want SAVE anything, UE4 writes stuff to Saved/Cooked/WindowsNoEditor/projectname subfolder, despite I have been set absolute path. I used FPaths::GameDir and then ConvertRelativePathToFull. (checked, the result is ok)
This is true for write methods of FFileHelper and FPlatformFileManager. Last time I tried to make a folder with CreateDirectory, but that also created in mentioned cooked folder. If I use standard C++ methods for file write or folder creation, it works correctly, but I would use rather UE4 methods. It is the same with development or debug builds.
What I miss here?


FString foldername = FPaths::GameDir() + L"Savegames/";
foldername = FPaths::ConvertRelativePathToFull(foldername);

GameDir give back relative path, then I change it to absolute.

which looks now for example
then after conversion I got F:\Spirits\Strategeist\Savegames, which is fine.

but despite this, FFileHelper.SaveStringToFile places the file to cooked/saved… folders.
also, creating a new directory with FPlatformFileManager::Get().GetPlatformFile().CreateDirectory() results the same, I got the new folder in Cooked/saved/WindowsNoEditor/projectname and seems UE4 ignores my absolute path.

Any suggestions?

hm it is so weird problem or I should explain it more better?

my pain is I cant use UE4 write methods for files/folders with absolute path, UE4 seems only sees inside Cooked/Saved? :open_mouth:

I also had this problem.

I wrote my solution here. A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums.

See the section. Sandbox File Path.

The short answer is, you need to call

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

Notice: GetFilenameOnDisk will check whether the file already exist. If file not exist, it will return the directory path.