How to delete a list from the SharePoint site using CSOM

Hi All,

In this post we are going see how to how to delete a list from the SharePoint site using CSOM.


Below code snippet shows basic operations to delete a list in SharePoint site.

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            // Get the context for the SharePoint Site
            ClientContext clientContext = new ClientContext("Enter your SharePoint Site URL");
            // Get the SharePoint list by title
            List olist = clientContext.Web.Lists.GetByTitle("Your Custom list");
            // Delete the custom list object 
            olist.DeleteObject();
            // Execute the query to the server
            clientContext.ExecuteQuery();
            //Check result for title property
            Console.WriteLine("List deleted");
            Console.ReadLine();
        }
    }
}
पुढे
« Prev Post
Previous
Next Post »