回收站查询,linq对对象集合的使用
public static void DeleteRecycleBinContent(SPRecycleBinOrderBy orderBy, bool ascending, string siteUrl)
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(siteUrl))
{
SPRecycleBinQuery query = new SPRecycleBinQuery();
query.ItemCollectionPosition = SPRecycleBinItemCollectionPosition.FirstPage;
query.ItemState = SPRecycleBinItemState.FirstStageRecycleBin;
query.RowLimit = 500;
query.IsAscending = ascending;
query.OrderBy = orderBy;
SPRecycleBinItemCollection binItems = site.GetRecycleBinItems(query);
var filteredItems = from i in binItems.OfType<SPRecycleBinItem>()
where i.ItemType == SPRecycleBinItemType.File && i.Title.Contains("YYY") && i.DeletedBy.LoginName == "basesmcdev2\\steve.curran"
select i;
if (filteredItems != null & filteredItems.Count() > 0)
filteredItems.First().Delete();
}
});
}