How do I get the full, absolute path of a content folder?

I have a directory for a folder using a folder picker widget and it goes something like “/Game/Meshes/Weapons”

It’s in the content folder but how do I get it so that it would be something like “D:/Project Directory/Content/Meshes/Weapons”

So how do I get it in C++?
I can work with a BP answer too though

Hey @Sweenus987!

I am not sure that there’s a way to do this, but why would you want to? Maybe if we could understand that there might be a different way to go about it. Typically UE projects stay within their bubble, so Game is the highest level, that way no matter where it gets installed it knows exact addresses for the files.

Could you give us a little more context? Thanks! :slight_smile:

Look at implementation for UKismetSystemLibrary::GetSystemPath - it uses the FPaths::ConvertRelativePathToFull method to get it

2 Likes

Ah yeah, I should have elaborated, my bad.

It’s for some image export functionality - baking a render target, material or material instance to either a UTexture or PNG.

For baking to a PNG, I’m using UImageWriteBlueprintLibrary::ExportToDisk and I’m just trying to get a good output path based on a directory that looks like “/Game/Meshes/Weapons” with the rest automatically filled in.

I could play around the UX of the process so that it would not be an issue - save it to a dedicated folder - but the idea is that you would have a folder on disk and in the UE project that would have the exported images & any that were then imported

Just tried FPaths::ConvertRelativePathToFull and it just returns the same value.

The specific input used was “/Game/DistanceFieldOutlineResources/” and I also used “/Game/DistanceFieldOutlineResources/test.png” and no joy.

I realised I could check to see if the path starts with either “/Game/” and remove it as there’s FPaths::ProjectContentDir and I could then just append. Not good if anyone else wants to expand on the code or something but as long I’m aware it should be fine, maybe :sweat_smile:

2 Likes

So, this is just a matter of using the appropriate (assume windows?) File I/O header and code.

Its fairly low level/basic. And you should be able to add it within your header without any issue so as to make custom calls to it.

Instead of using Unreal methods for it, just use the native ones.

Writing the stream to the file should be trivial since I know for a fact there is an engine function that makes the stream accessible…

1 Like