Delete Folder in SharePoint using CSOM

The example in this topic show how to use CSOM to Delete Folder in SharePoint

  • using Microsoft.SharePoint.Client;
  • using System.Linq;
  •  
  • using (ClientContext clientContext = new ClientContext("http://MyServer/sites/MySiteCollection"))
  • {
  • // Enter server relative URL of the folder
  • Folder targetFolder = clientcontext.Web.GetFolderByServerRelativeUrl("Lists/New%20list/aa");
  •  
  • // Delete target folder
  • targetFolder.DeleteObject();
  •  
  • clientcontext.ExecuteQuery();
  • }

Thank you for reading this article. This code was tested in SharePoint 2013


© 2019 Code SharePoint