SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have document library which have folder and sub folder. the folder and sub folder level is more than 5. like as follow :

Document Library
   |-> Folder-1
   |   -> Folder-1-1
   |      -> Folder-1-1-1
   |         -> Folder-1-1-1-1
   |            -> Folder-1-1-1-1-1
   |               -> Document1.doc
   -> Folder-2
   |   -> Folder-2-1
   |      -> Folder-2-1-1
   |         -> Folder-2-1-1-1
   |            -> Folder-2-1-1-1-1
   |               -> Document2.doc

now i want a CAML Query that search the document from all folders of document library and list them in grid view. if i search "men" then it will display documents in Grid view which contains "men" in there Title Field

share|improve this question
up vote 0 down vote accepted

Your CAML query should look like this:

         <FieldRef Name='FileLeafRef' />
         <Value Type='File'>men</Value>

And specify the ViewAttribute of SPQuery to Recursive so that documents within folders are also displayed. oQuery.ViewAttributes = "Scope=\"Recursive\"";

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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