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 a folder in document library.

If I get the folder from folder collection of the document library and only query the items inside that folder will it work faster then querying a whole library using the recursive attribute? Just to be clear I only need the items that reside inside that folder.

share|improve this question
up vote 3 down vote accepted

Yes definitely it will be faster, as less items will be retrieved and stored in memory.

Here's sample code,

public void SaveFolderFiles(string fileName, string libraryName, ClientOM.ClientContext clientContext)
        ClientOM.List sharedDocumentsList = clientContext.Web.Lists.GetByTitle(libraryName);
        ClientOM.CamlQuery camlQuery = new ClientOM.CamlQuery();
        camlQuery.FolderServerRelativeUrl = "/Site/Folder/Folder2010/";
        camlQuery.ViewXml =
                  <FieldRef Name='FileLeafRef'/>
                  <Value Type='Text'>" + fileName + @"</Value>
        ClientOM.ListItemCollection listItems = sharedDocumentsList.GetItems(camlQuery);
        if (listItems.Count == 1)


CamlQuery.FolderServerRelativeUrl property is the key

share|improve this answer
thanks mate , by the way can you post here an example of caml where items from only a particular folder in the doc library are accessed – user8189 May 1 '13 at 15:46
Check updated answer. – Muhammad Raja May 1 '13 at 15:52

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.