Calculate total files of SharePoint online via CSOM c#

Amit 691 Reputation points
2021-01-28T07:00:18.987+00:00

My application is calculating total Files within my domain of SharePoint online. Traversing through each and every list then count attachment and files (in the case of the doc library) is really time-consuming.
Is there anything we can do it fast like any CSOM API to get files from the website or site collection itself?

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,073 questions
SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,591 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Amos Wu-MSFT 4,051 Reputation points
    2021-01-29T03:04:33.96+00:00

    You could try to use search to get the count of the files and attachments in the site collection.
    Using the SharePoint search Query APIs


    If the response is helpful, please click "Accept Answer" and upvote it.
    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.