Delete a list from the SharePoint 2013 using CSOM

Steps
  • Open Visual Studio in your system
  • Select Console Applciation template and give as name "DeleteList"
  • Add a Microsoft.Cleint Assembly refrence file in right side refrence tab in visual studio.
  • Replace Program.cs with the source code below.
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Text;  
  5. using System.Threading.Tasks;  
  6. using Microsoft.SharePoint.Client;  
  7. namespace DeleteList  
  8. {  
  9. class Program  
  10. {  
  11. static void Main(string[] args)  
  12. {  
  13. // ClientContext - Get the context for the SharePoint Site  
  14.   
  15. ClientContext clientContext = new  
  16. ClientContext("http://gauti.sharepoint.com/sites/SP/");  
  17. // Get the SharePoint web  
  18.   
  19. Web web = clientContext.Web;  
  20.   
  21. // Get the SharePoint list by Title  
  22.   
  23. List list = web.Lists.GetByTitle("NewList");  
  24.   
  25. // Delete the list object  
  26.   
  27. list.DeleteObject();  
  28.   
  29. // Execute the query to the server.  
  30.   
  31. clientContext.ExecuteQuery();  
  32. }  
  33. }  
Output

Hit F5 and see the magix happend in SharePoint 2013. Hope you have enjoyed this.!!! :-)
Ebook Download
View all
Learn
View all