Documentation > CMS Template API Library > Asset > Delete()

Delete

Deletes the current asset instance. It is marked for deletion and purged from the database after 2 weeks. The current user must have permission to delete the asset. The root asset (id == 0), may not be deleted.

public System.Boolean Delete()


Returns

True if successful, false if nothing is removed. There may be an accompanying error if false is returned, but not if the asset was not loaded.

Parameters

NameDescriptionType

Code Example

C#

Sample:
Asset toRemove = Asset.Load("/Path/Toremove");
if (!toRemove.Delete())
Out.DebugWriteLine("Failed to remove asset id {0} error {1}",toRemove.Id, context.Error);

Connect with Crownpeak