Restore Recycle Bin Items From SharePoint Site Using CSOM
Softree Technology > Blogs > SharePoint > Restore Recycle Bin Items From SharePoint Site Using CSOM

Restore Recycle Bin Items From SharePoint Site Using CSOM

  • Posted by: Softree Technology

What is Recycle Bin?

A Recycle Bin is a temporary storage location for deleted items from that site.

When we delete an item first it goes to First Stage Recycle Bin and stay there for a short-term period then it moves to second stage recycle bin. In case of permanent deletion, we need to delete it again from second stage recycle bin.

Sometimes we may require this item again in that case simply we need to restore it back from Recycle Bin. It can be restored by both manually and programmatically.

Here I am going to explain how to Restore Recycle Bin Items from a SharePoint Site using Client Side Object Model (CSOM).

By using below steps we can restore all items present in Recycle Bin section.


  1. Retrieve Recycle Bin Items from site.
  2. Restore it.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SharePoint.Client;
using System.Security;

namespace RestoreRecyclebinSharepointItem
    class Program
        static void Main(string[] args)
            SecureString pwd = new SecureString();
            string Username ="";
             string password = "Password";
       using (ClientContext ctx = new ClientContext(""))

                foreach (char c in password.ToArray())

                ctx.Credentials = new SharePointOnlineCredentials(Username, pwd);

                RecycleBinItemCollection recycleBinItems = ctx.Site.RecycleBin;

                //Restore all items from Recycle Bin
                Console.WriteLine("item restored");
           catch (Exception ex) { }
  1. Before execution of program.

2. After execution of program.

From the above article we have learnt how to restore items from Recycle Bin programmatically with help of CSOM.

• Restore SharePoint Recycle bin items
• Restore Recycle bin using CSOM
• Retrieve and Restore SharePoint Recycle bin items

Author: Softree Technology

Leave a Reply