Saturday, May 26, 2012

How to delete a file in sharepoint 2010

Here i will give an simple code for how to delete a file in sharepoint2010.For this i got the all files in existing list then delete a file using file index in list of files.
ClientContext clc = new ClientContext(url);
Web w = clc.Web;
List li = w.Lists.GetByTitle("City");
clc.Load(li);
var files = li.RootFolder.Files;
FileCollection fc =files;
clc.Load(fc);
clc.ExecuteQuery();
File Deleteitemfile = fc[3];          
Deleteimtefile.DeleteObject();
clc.ExecuteQuery();

Post a Comment

Bel