Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7594721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:29:28+00:00 2026-05-30T21:29:28+00:00

Is it possible to get all files by content type in the whole site

  • 0

Is it possible to get all files by content type in the whole site collection? This is the code I currently have:

//Get list of subsites to traverse
            List<string> subsites = getSubSiteList();
            foreach (string siteUrl in subsites)
            {
                using (SPWeb web = new SPSite(siteUrl).OpenWeb())
                {
                    if (web.GetFolder("Pages").Exists)
                    {
                        //Get Pages Folder from subsite                    
                        SPFolder folderCol = web.Folders["Pages"];

                        //Set files in Pages folder
                        SPFileCollection fileCol = folderCol.Files;
                        foreach (SPFile file in fileCol)
                        {
                            //Debug.WriteLine("File in site: " + siteUrl + " file: " + file.Name);
                        }
                    }
                    web.Dispose();
                }
            }

In this code I am iterating through all the subsites and going to the “Pages” folder to get a certain page, but I would like to be able to just pull all these files without having to go through each subsite, and getting it by content-type instead of going inside the “Pages” folder and parsing from there. How would the code look? Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T21:29:30+00:00Added an answer on May 30, 2026 at 9:29 pm

    What you’re looking for is a site data query.

    Other options would be to programmatically leverage the search functionality, but I don’t think it’s as good as an option; the site data query is literally designed for exactly this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to be able to get a list of all possible files
Possible Duplicate: Get all files from VSS for a given date? I need to
Is it possible to get all/latest tweets from twitter public list? Example list: https://twitter.com/#!/thecaucus/u-s-senate
Is it possible to get all 7 days for a given date using linq
Is it possible to get all div's within a page using jQuery including nested
In C#, is it possible to get all values of a particular column from
Is there a way to get all possible values from a MySQL enum column?
I would like to get all possible available currencies. Java 7 had provided such
Possible Duplicate: How to get all of the IDs with jQuery? How can i
Possible Duplicate: Printing Table's structure/schema oracle has 'DESCRIBE' to get all the details of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.