Creating a package in c++: "Path does not map to any roots"

I am using an AssetFactory to enable asset creation for a custom asset type via drag and drop in the editor. As the asset does contain some additional data, I want to create a subdirectory where I store that data in. To do so, I create another package with the path of the subdirectory:

// This comes from an AssetFactory
UObject* RootPackage = ...;  // The directory where the asset was dragged into in the editor (UPackage)
FString FilePath = ...;  // The path to the file that was dragged into the editor

// Extracting the directories and filename
FString Directory, FileName, PackagePath;
FImportUtils::SplitPath(RootPackage->GetFullName(), PackagePath, FileName);
FImportUtils::SplitPath(FilePath, Directory, FileName);

// First create the new directory - this does work just as expected
const FString NewPackagePath = FPaths::Combine(PackagePath, TEXT("MySubdirectory"));
// Chop these 14 characters: "Package /Game/"
const FString PackageAbsolutePath = FPaths::ConvertRelativePathToFull(FPaths::Combine(FPaths::ProjectContentDir(), NewPackagePath.RightChop(14)));
FImportUtils::VerifyOrCreateDirectory(PackageAbsolutePath);

// Now create a package for the new subdirectory (but is this even necessary?)
UPackage* NewPackage = CreatePackage(*NewPackagePath);

// Some code that creates an asset inside of the subdirectory (subpackage)
UObject* NewAsset = ...;

// Save the new asset (copied from this blogpost: https://isaratech.com/save-a-procedurally-generated-texture-as-a-new-asset/)
FString PackageFileName = FPackageName::LongPackageNameToFilename(
NewPackage->GetName(), FPackageName::GetAssetPackageExtension());
UPackage::Save(NewPackage, NewAsset, RF_Standalone | RF_Public, *PackageFileName);

When running this code, I get the following error for the LongPackageNameToFilename command:
“Path does not map to any roots”

The path does exist, however, it was freshly created (successfully), so no I am wondering if it is even necessary to create a new package, or if I can create the assets in the original package with a different path. Unfortunately, I could not find any information at all what a “package” even is or what the difference between a package and an asset actually is.

While I was not able to find the source of the error, I was able to get the code working as I intended.
Instead of creating a package that represents a directory and let multiple assets (inside that directory) use the same package, I created a package for each asset that I was creating.
Therefore, I changed the NewPackagePath to something like this for each asset:

FPaths::Combine(PackagePath, TEXT("MySubdirectory"), TEXT("MyAsset"))

Doing so I did not get any more errors and the assets got saved as expected.