At any circumstances we cannot retrieve more than 5000 items from SharePoint list, so we must use the rowlimit parameter in the camel query, as I see you have already used it. If we have a filter in camlquery, the rowlimit parameter will not work and you will get exceed threshold limit exception. What we can do is to fetch all items iclude folders by first camlquery
<View><Query><OrderBy Override ="TRUE"><FieldRef Name="FileDirRef" /><FieldRef Name="FileLeafRef" /></OrderBy></Query><RowLimit Paged="TRUE">{0}</RowLimit></View>
Then keep it in collection object and filter files by following code
foreach (ListItem item in listCol){
if (item.FileSystemObjectType == FileSystemObjectType.File){
ListItems.Add(items);
}
}
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.