Speed up widget development with Sitefinity MCP server. Learn more...

Create document libraries

When creating a document library, you must perform the following steps:

  1. Check whether the document library already exists.

    Before you create the document library, you must check whether a document library with the same ID already exists.

  2. Create the document library.

    If the document library does not exist, you create a new document library with the specified ID.

  3. Set the required properties.

    When creating a new document library, it is recommended to set at least the following properties:

    • Title
    • LastModified
    • DateCreated
    • UrlName

    You can also set any other properties in this step.

  4. Save the document library.

    Save all changes that you have made to the document library.

The example below shows you how to create a document library with predefined ID.

Creating a document library with predefined ID

The following code creates a document library with the specified ID and Title.

Native API


First, you get an instance of the LibrariesManager class. You check whether a document library with the same ID already exists. To create the document library, you call the CreateDocumentLibrary method of the LibrariesManager class and pass the specified ID. You can create a document library with either predefined or auto-generated ID depending on which overload of the method you use. Then, you set the properties of the document library object. It is recommended to set at least the following properties: TitleUrlNameLastModified,DateCreated. Finally, to save the document library, you call the SaveChanges method of the manager.

Fluent API


First, you check whether a document library with the same ID already exists. To create the document library, you call the CreateNewmethod of the singular document library facade. You can create a document library with either predefined or auto-generated ID depending on which overload of the method you use. To set the properties of the document library, you call the Do method of the facade. Finally, you save the changes.

NEW TO SITEFINITY?

Want to learn more?

Enhance your Sitefinity skills by enrolling in free training sessions. Become Sitefinity certified through Progress Education Community to strengthen your professional credentials.

Get started with Integration Hub | Sitefinity Cloud

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting your Sitefinity instance and its sites from external threats. 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 ASP.NET Core and take advantage of its decoupled architecture and modern development model.

Was this article helpful?