0

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?

  • What version of sharepoint do you have? – Hawk Nov 22 '20 at 21:32
  • Hello Hawk, we are using SharePoint 365 online – Elie Michel Nov 23 '20 at 7:30
0

Check the threshold from Central Administration -> Manage Web Applications

Select the Web App -> from Ribbon Click on General Settings -> Resource Throttling

Then increase the threshold if it is still on the default value 5000

enter image description here enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.