How to create folders in content browser using C++

I am trying to create folder in content browser using c++, but i am unable to do that.
I could not any method in source code to that or to register the created folder with content browser.

Can anyone one know how to do that ?

Thanks in advance.

It’s actually the asset registry that you’d need to add the path to:

FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry");

That said, if you create a new folder* on disk it should just appear in the Content Browser.

*Caveat: Currently you’ll also need to create an asset within the new folder, as the Asset Registry directory watcher doesn’t watch for directory changes. Someone is working on fixing this for 4.22.

1 Like

Thanks @Jamie Dale ,
I tried to create the folder manually, but i order to reflect that change i need to restart the engine !
“FAssetRegistryModule”,Its different module ! Can you give me little coding help like how should i implement this in my code.

I just need to create “Folder” in content browser(effectively in hard disk also )
using c++ and import my assets into that folder using my plugin ??
(Any snippet or coding reference will be helpful)

Thanks in advance

If you’re importing assets into the folder (they have to be saved afterwards so that they create a .uasset file on disk), then the Asset Registry will automatically detect those assets and notify the Content Browser without you having to do anything special in your code.

If you want to keep the assets in-memory only (so that the user has to save them), then you’ll have to notify the Asset Registry yourself. This would be as simple as calling AssetCreated and passing in your newly imported asset (this will implicitly create the folder too).

FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry");
for (UObject* NewAsset : NewAssetsImported)

i want to do the first one !!

what code should i do ??

FEditorFileUtils::SaveDirtyPackages should save everything that’s dirty after your import (including anything that was dirty before your import!).

Alternatively, if you know what you imported (and therefore what you want to save) then you can use UEditorLoadingAndSavingUtils::SavePackages.

FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked"AssetRegistr" AssetRegistryModule.Get().AddPath(YourPath);

Gave me the folder but, how can i import assets inside the created folder ?

And also when ever i am creating folder though above method, the folder is not created in my hard disk, while i right click and create new folder unreal is physically creating the folder in hard disk.

Is there any plugin used in unreal which will create folder, you know, so that i can look in the code and understand which steps i am missing ??

Thanks @Jamie Dale

For importing, take a look at UAssetImportTask and UAssetToolsHelpers::GetAssetTools().ImportAssetTasks (you can also use those in Python).

Telling the asset registry a path exists doesn’t actually create the folder. That is expected. If you do also want to create the folder prior to importing your assets (which would implicitly create the folder for you), then you’ll could use UEditorAssetLibrary::MakeDirectory (which will also notify the asset registry).