TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
RecycleBin Items Using CSOM
Shantha Kumar T
Dec 28
2015
Code
4.3
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
//CSOM Assembly version - 16.1.4727.1200
//using Microsoft.SharePoint.Client
//GetFirstStageRecyclebinItems(credentials, weburl);
private
static
void
GetFirstStageRecyclebinItems(SharePointOnlineCredentials credentials,
string
weburl)
{
RecycleBinItemCollection recyclebinItems =
null
;
using
(ClientContext ctx =
new
ClientContext(weburl))
{
ctx.Credentials = credentials;
Web oweb = ctx.Web;
//SP.Web.GetRecycleBinItems : retrieves the deleted items from the web site.
//Row Limit - 100 : Returns deleted items upto 100
//RecycleBinOrderBy.DefaultOrderBy - Order the items by default
//RecycleBinItemState.FirstStageRecycleBin - returns the items only from first stage
recyclebinItems = oweb.GetRecycleBinItems(
null
,100,
false
, RecycleBinOrderBy.DefaultOrderBy, RecycleBinItemState.FirstStageRecycleBin);
ctx.Load(recyclebinItems);
ctx.ExecuteQuery();
}
Console.WriteLine(
"Total deleted items:"
+ recyclebinItems.Count.ToString());
//RecycleBinItem.ItemType - Returns the type of the deleted object
//RecycleBinItem.LeafName - Returns the item name / file name of the object
foreach
(RecycleBinItem item
in
recyclebinItems)
Console.WriteLine(item.ItemType +
" - "
+ item.LeafName);
Console.WriteLine(
"Press any key to exit..."
);
Console.Read();
}
Recyclebin