I'm trying to programmatically restore documents from the sharepoint recycle bin. In an external database, the document IDs are stored, and I'm looking to restore item(s) according to some document Id(s).
I'm fairly certain this information must be kept, as the document IDs are preserved whenever I manually delete/restore them.
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite mySite = new SPSite("http://mysharepoint/sites/mysite")){
SPRecycleBinQuery query = new SPRecycleBinQuery
{
RowLimit = 200,
ItemState = SPRecycleBinItemState.FirstStageRecycleBin,
OrderBy = SPRecycleBinOrderBy.DeletedDate,
ItemCollectionPosition = SPRecycleBinItemCollectionPosition.FirstPage
};
SPRecycleBinItemCollection coll = mySite.GetRecycleBinItems(query);
foreach(SPRecycleBinItem item in coll )
{
???
}
});
The above code snippet works fine (assuming max of 200 items for the moment) for getting all deleted documents. The closest to an ID property that an SPRecycleBinItem item has is GUID. Is it possible to determine the doc ID from that?