Run the code with elevated
code needs to be executed
private void DeleteTempPDFs(List<SPListItem> convertedItems)
{
// Elevate the privileges to run code as AppPool administrator
SPSecurity.RunWithElevatedPrivileges(() =>
{
using (SPSite site = new SPSite(SPContext.Current.Site.ID))
using (SPWeb web = site.OpenWeb())
{
foreach (SPListItem item in convertedItems) {
web.Lists[item.ParentList.ID].GetItemById(item.ID).Delete();
}
}
});
}
code needs to be executed
private void DeleteTempPDFs(List<SPListItem> convertedItems)
{
// Elevate the privileges to run code as AppPool administrator
SPSecurity.RunWithElevatedPrivileges(() =>
{
using (SPSite site = new SPSite(SPContext.Current.Site.ID))
using (SPWeb web = site.OpenWeb())
{
foreach (SPListItem item in convertedItems) {
web.Lists[item.ParentList.ID].GetItemById(item.ID).Delete();
}
}
});
}
No comments:
Post a Comment