SPSecurity.RunWithElevatedPrivileges(delegate { using (SPSite site = new SPSite("http://servername")) { using (SPWeb web = site.RootWeb.Webs["webname"]) { try { SPListItem itm = web.GetListItem("fileurl"); itm.Delete(); } catch (Exception ex) { Console.WriteLine(ex.Message); } } } });