I have a custom recycle bin report. I would like to know how to determine if a SPRecycleBinItemType of type folder contains any files in SP2010.

I have rummaged the OM and have not found a property to answer the question.

1 Answer 1


I don't think there is any direct way to check if SPRecycleBinItemType of type folder contains any files as there is also no way to check from UI also.

But one think you can do is to check the size of the SPRecycleBinItemType item. As it would not give you size as 0 for empty folder but less the 1 KB. You can probably make a check on this property.

using (SPSite site = new SPSite(SPContext.Current.Web.Url))
                using (SPWeb spweb = site.OpenWeb())
                    SPRecycleBinQuery objQuery = new SPRecycleBinQuery();
                    objQuery.RowLimit = 100;
                    objQuery.OrderBy = SPRecycleBinOrderBy.Default;
                    SPRecycleBinItemCollection recycleitems = spweb.GetRecycleBinItems(objQuery);
                    foreach (SPRecycleBinItem item in recycleitems)
                        SPRecycleBinItemState state = item.ItemState;
                        if(item.ItemType == SPRecycleBinItemType.Folder)
                            long size = item.Size;
  • I think this is as close as we can get. And it is an excellent approach. On my system an empty is 152 bytes. Commented May 27, 2014 at 15:43
  • Great.. you can create a check around this only.
    – Aanchal
    Commented May 27, 2014 at 15:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.