Create folders inside libraries

  1. The following code creates a folder under a specified parent by parent



First, you get an instance of the 
LibrariesManager class. Then create an album. See here more info for For developers: Create image librariesTo create the album, you call the CreateAlbum method of the LibrariesManager class. You can create an album with either predefined or auto-generated ID depending on which overload of the method you use. Then, you set the properties of the album object. In our sample we are only setting the Title property. Finally, to save the album, you call the SaveChanges method of the manager.

Then we create a folder using the CreateFolder method of the LibrariesManager by using the album created in the previous step as a parameter. Folders have the following properties:

- Id
- Title
- Description
- UrlName
- ParentId


In our example we are not setting the Id, leaving it to be created automatically, set the Title, Description and UrlName. Finally you have to call the SaveChanges method of the manager in order to save the folder.

2. This example creates new folder under a specified parent by specifying folder id and parent:


Here we are creating an album first similar to the first example and later we are creating  a folder by specifying id and album. 

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Web Security for Sitefinity Administrators

The free standalone Web Security lesson teaches administrators how to protect your websites and Sitefinity instance from external threats. Learn to configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?

Next article

Get folders