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.


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

| 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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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