Documentation > CMS Template API Library > Asset > CreateFile(String,Asset,Asset,Asset)

CreateFile

This function creates a new asset in the cms with the specified label, template and optional workflow in the specified saveLocation.

public CrownPeak.CMSAPI.Asset CreateFile(String,Asset,Asset,Asset)


Returns

The asset that is created. Upon failure it will return an empty asset and you will need to check the IsLoaded property to see if it was successfully created or Not.

Parameters

NameDescriptionType
label The label System.String
saveLocation The save location. CrownPeak.CMSAPI.Asset
template The template. CrownPeak.CMSAPI.Asset
workflowAsset Optional: The workflow asset usually specified in /System/Workflows or within the workflows foloder within a project. If no asset is provided no workflow is assigned CrownPeak.CMSAPI.Asset

Code Example

C#

Sample:
Asset workflowAsset = Asset.Load("/System/Workflows/Basic Workflow");
Asset saveLocation = Asset.Load("/My Site/My Folder/");
Asset asset = Asset.CreateFile("foo", saveLocation, template, workflowAsset);
if(asset.IsLoaded)
{
  //do something with the newly created asset.
}

Connect with Crownpeak