Hi @Anonymous ,
You can get recycle bin data by following code
string userName = "xxx@xxx.onmicrosoft.com";
Console.WriteLine("Enter your password.");
SecureString password = GetPassword();
// ClienContext - Get the context for the SharePoint Online Site
using (var clientContext = new ClientContext("https://xxx.sharepoint.com"))
{
// SharePoint Online Credentials
clientContext.Credentials = new SharePointOnlineCredentials(userName, password);
// Get the SharePoint web
Web web = clientContext.Web;
// Get all the recycle bin items
// Reference: https://msdn.microsoft.com/EN-US/library/microsoft.sharepoint.client.recyclebinitem_members.aspx
RecycleBinItemCollection rbiColl = web.RecycleBin;
clientContext.Load(rbiColl);
// Execute the query to the server
clientContext.ExecuteQuery();
// Loop through each recycle bin item
foreach (RecycleBinItem rbiItem in rbiColl)
{
Console.WriteLine(rbiItem.Title);
}
Console.ReadLine();
}
}
private static SecureString GetPassword()
{
ConsoleKeyInfo info;
//Get the user's password as a SecureString
SecureString securePassword = new SecureString();
do
{
info = Console.ReadKey(true);
if (info.Key != ConsoleKey.Enter)
{
securePassword.AppendChar(info.KeyChar);
}
}
while (info.Key != ConsoleKey.Enter);
return securePassword;
The folder is monitored as an item, so we are unable to retrieve the change logs of the files under the deleted folder. Here is the document for more details
https://github.com/pnp/PnP/tree/master/Samples/Core.ListItemChangeMonitor
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.