I have a SharePoint where I can do (CRUD) operations in the browser on a particular folder. I am trying to get all the folders using C# code
// Test code
try
{
ClientContext context = new ClientContext(url);
context.Credentials = new SharePointOnlineCredentials("username", GetSecureString("password"));
Web sites = context.Web;
context.Load(sites, website => website.Folders);
Folder folders = sites.RootFolder;
context.ExecuteQuery();
Console.Out.WriteLine(folders.Folders.Count);
Console.ReadLine();
}
catch (Exception e)
{
Console.Out.WriteLine(e.Message); Console.ReadLine();
}
I got an exception
"Access denied. You are not authorized to perform this action or access this resource.".
Can anyone help me out how to solve the issue?