# Delete document libraries

This topic explains how to delete document libraries. The examples below show you how to delete all of the available document libraries or how to delete only a specific document library by its *ID*.

## Deleting a single document library

When deleting a specific document library by its *ID*, you must perform the following:

1. *Get the document library.*

   First, get an instance of the document library that corresponds to the specified ID.
2. *Delete the document library.*

   Mark the document library to be deleted and save the changes.

The following code deletes a document library by its *ID*.

**Native API**

```C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Telerik.Sitefinity.Libraries.Model;
using Telerik.Sitefinity.Modules.Libraries;

namespace Telerik.Sitefinity.Documentation.CodeSnippets.DevGuide.SitefinityEssentials.Modules.MediaModules.DocumentsAndFiles.ManagingLibraries
{
    public partial class LibrariesSnippets
    {
        private void DeleteDocumentLibraryNativeAPI(Guid documentLibraryId)
        {
            LibrariesManager manager = LibrariesManager.GetManager();

            DocumentLibrary library = manager.GetDocumentLibraries().Where(b => b.Id == documentLibraryId).SingleOrDefault();

            if (library != null)
            {
                //Mark the library to be deleted.
                manager.DeleteDocumentLibrary(library);

                //Save the changes.
                manager.SaveChanges();
            }
        }
    }
}

```

First, you get an instance of the *LibrariesManager* class. Then, you get the document library with the specified *ID*. To mark the document library to be deleted, you call the DeleteDocumentLibrary method of the manager with the instance of the document library as an argument. Finally, you save the changes.

**Fluent API**

```C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Telerik.Sitefinity.Documentation.CodeSnippets.DevGuide.SitefinityEssentials.Modules.MediaModules.DocumentsAndFiles.ManagingLibraries
{
    public partial class LibrariesSnippets
    {
        private void DeleteDocumentLibraryFluentAPI(Guid documentLibraryId)
        {
            App.WorkWith().DocumentLibrary(documentLibraryId).Delete().SaveChanges();
        }
    }
}

```

First, you get the singular facade of the document library with the specified *ID*. To mark the document library to be deleted, you call theDelete method of the facade. Finally, you call SaveChanges.

## Deleting all document libraries

When deleting all document libraries, you must perform the following:

1. *Get all document libraries.*

   Get instances of the available document libraries.
2. *Delete each document library in the collection.*

   Iterate through the collection and delete each library.

The following code deletes all document libraries.

**Native API**

```C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Telerik.Sitefinity.Libraries.Model;
using Telerik.Sitefinity.Modules.Libraries;

namespace Telerik.Sitefinity.Documentation.CodeSnippets.DevGuide.SitefinityEssentials.Modules.MediaModules.DocumentsAndFiles.ManagingLibraries
{
    public partial class DeleteAllLibrariesNativeAPI
    {
        private void DeleteAllDocumentLibrariesNativeAPI()
        {
            LibrariesManager manager = LibrariesManager.GetManager();

            var documentLibraries = manager.GetDocumentLibraries().ToList();

            foreach (DocumentLibrary library in documentLibraries)
            {
                manager.DeleteDocumentLibrary(library);
            }

            manager.SaveChanges();
        }
    }
}

```

First, you get an instance of the *LibrariesManager* class. Then, you get all of the available document libraries. You iterate through the collection and mark each document library to be deleted. Finally, you save the changes.

**Fluent API**

```C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Telerik.Sitefinity.Documentation.CodeSnippets.DevGuide.SitefinityEssentials.Modules.MediaModules.DocumentsAndFiles.ManagingLibraries
{
    public partial class DeleteAllLibrariesFluentAPI
    {
        private void DeleteAllDocumentLibrariesFluentAPI()
        {
            App.WorkWith().DocumentLibraries().Delete().SaveChanges();
        }
    }
}
```

First, you get the plural document libraries facade. To mark each item to be deleted, you call the Delete method of the facade. Finally, you save the changes.
