Documentation > CMS Template API Library > Asset > CreateFolder(String,Asset,FolderType)

CreateFolder

Creates a folder in the given location using the given FolderType

public CrownPeak.CMSAPI.Asset CreateFolder(String,Asset,FolderType)


Returns

The newly created folder. If it fails an unloaded asset is returned, use IsLoaded to check

Parameters

NameDescriptionType
label The name of the asset. System.String
saveLocation The folder to save this asset. CrownPeak.CMSAPI.Asset
folderType Optional: The type of folder you want to create. The default value is FolderType.Folder. Note: If you would want to create a library reference please use Asset.CreateLibraryReference. Additionally, if creating a project the default name "library" will be used to name the library folder. CrownPeak.CMSAPI.FolderType

Code Example

C#

Sample:
Asset projectTemplateFolder = Asset.Load("/Site/myProjectFolder/Templates");
//Create the folder.
Asset nestedTemplateFolder = Asset.CreateFolder("nested template folder name", projectTemplateFolder, FolderType.TemplateFolder);
if (!nestedTemplateFolder.IsLoaded)
Out.WriteLine("Create Failed: " + context.Error);

Connect with Crownpeak