Documentation > CMS Template API Library > Asset > CreateLibrary(String,Asset)
CreateLibrary
Create a library with the given label in the given location.
public CrownPeak.CMSAPI.Asset CreateLibrary(String,Asset)
Returns
A newly created library.
Parameters
| Name | Description | Type |
|---|---|---|
| label | The label to use | System.String |
| project | The folder where the library is to be created. Must be a project | CrownPeak.CMSAPI.Asset |
Code Example
C#
Sample:
string label = "CPTest Library";
Asset project = Asset.Load("/" + asset.AssetPath[0] + "/Project/");
if(project.IsLoaded)
{
// Note: A project may have only one local library.
// If one exists already a new one won't be created.
Asset newLibrary = Asset.CreateLibrary(label, project);
if(newLibrary.IsLoaded)
{
// Do Something
}
}