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

  • Home
  • SEARCH
  • 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 620745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:47:51+00:00 2026-05-13T18:47:51+00:00

I am using code like the following to get a list of all documents

  • 0

I am using code like the following to get a list of all documents in a site with SPSiteDataQuery however, it is returning all sorts of documents that were not uploaded by the user. What is the best way to filter the list to only those documents that a user would have uploaded?

I am suspecting that there is a query that I can use but I am not sure what FieldRef I should be using to find only user uploaded documents (not hidden or system type document files).

see *** below in the method

thanks

        protected DataTable GetListDataSPSiteDataQuery(string siteUrl, bool recursive, ref string error) {
            DataTable results = null;

            using (SPSite site = new SPSite(siteUrl)) {
                SPWeb web = site.OpenWeb();
                SPSiteDataQuery query = new SPSiteDataQuery();

                //query.Webs = "<Webs Scope='SiteCollection' />"; //query all web sites in site collection
                if (recursive)
                    query.Webs = "<Webs Scope='Recursive' />";


                query.Lists = "<Lists ServerTemplate='101' Hidden='FALSE' MaxListsLimit='0' />";
                //query.Lists = "<Lists BaseType='1' MaxListsLimit='0' />"; //document library only (0=generic list, 1=doc library,3=discussino forum,4-vote or survey,5=issues list)

                // *** can i provide a query here to filter for the documents i am interested in?
                query.Query = string.Empty; 

                //query.Query = "<Where>" + 
                //                    "<Gt>" +
                //                        "<FieldRef Name='File_x0020' />" +
                //                        "<Value Type='Number'>0</Value>" +
                //                    "</Gt>" +
                //                "</Where>";

                query.ViewFields = _viewFields;


                results = web.GetSiteData(query);
            }
            return results;
        }
  • 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-13T18:47:51+00:00Added an answer on May 13, 2026 at 6:47 pm

    I’m not on the office right now to test but try adding the following fields to the result (so you can see if they create a filterable pattern)

    • ContentType (look for the obnoxious ones, like _Hidden)
    • CreatedBy (Author should be SHAREPOINT\system for non-user files)

    I will try to get a test going if this doesn’t help, but I do not think there’s the big elephant in the room that says ONLY_USER_CREATED besides those properties. If the “all sorts of documents not uploaded by the user” are ONLY the /forms/ folder files (AllItems.aspx, EditItem.aspx etc) it can probably be worked around with a few Contains tests.

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

Sidebar

Related Questions

I've got some code that looks like this: using (DBDataContext dc = new DBDataContext(ConnectionString))
In VB.NET I'm drawing an ellipse using some code like this. aPen = New
Using preview 4 of ASP.NET MVC Code like: <%= Html.CheckBox( myCheckBox, Click Here, True,
I have just been re-working an old bit of compiler-like code written using bison.
If I'm using a Hashtable , I can write code like this: object item
I'm using PHP5 to create XML files. I have code like this: $doc =
I'm looking for something like break for loops. Here's some example code (using Symfony's
I've been doing code review (mostly using tools like FindBugs) of one of our
I'm using .NET Regular Expressions to strip HTML code. Using something like: <title>(?<Title>[\w\W]+?)</title>[\w\W]+?<div class=article>(?<Text>[\w\W]+?)</div>
I'm using code that I found on the CodeProject.com for a low-level keyboard hook

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.