I have an issue with Sharepoint CSOM when I am trying to get subfolder with the following code
public void LoadFolders(Folder folder, SharePointFolder sharePointFolder)
{
Context.Load(folder.Folders);
Context.ExecuteQuery();
foreach (var subFolder in folder.Folders)
{
var subRootFolder = new SharePointFolder(sharePointFolder, subFolder);
sharePointFolder.SubFolders.Add(subRootFolder);
}
}
I get the error below when trying to load subfolders of a folder that has an itemCount of more than 5000.
Microsoft.SharePoint.Client.ServerException
HResult=0x80131500
Message=The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator.
Source=Microsoft.SharePoint.Client.Runtime
StackTrace:
at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream)
at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()
at Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder sb)
at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()
at ..SharePointApi.SharepointSdkAccessMethod.LoadFolders(Folder folder, SharePointFolder sharePointFolder) in ..\..\SharePointApi\SharepointSdkAccessMethod.cs:line 435
at ..SharePoint.ViewModels.SharePointFoldersViewModel.<>c__DisplayClass30_0.<GetFolderAsync>b__0() in ..\..\ViewModels\SharePointFoldersViewModel.cs:line 183
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
Is there a way to resolve this issue or a CamlQuery that can give the same result as my function above?