I have a Library, which stores document sets (the content type here is a documentset which contains more than one word document). Currently I can to get the items from the library using the below code

CamlQuery q = new CamlQuery();
var items = list.GetItems(q);

Which is giving the document sets properly. Now how can I get access to the word document files contained in each document set returned from the above code. I am using client object model. Thanks.

3 Answers 3


A document set is a special sort of folder. The items in the document set can be retrieved as you would in a 'regular' folder. Enumerate through the items returned in the success function and call get_file() on the item.

  • Thank you for directing me.. its helpful to know that document set is a special type of folder.. But as I am using client object model I can't use get_file() however I managed to get a solution based on your answer.Thank you.
    – Flowerking
    Mar 28, 2012 at 12:17
  • My document set contains a word document as a link. When I try to get the filename, it is giving as wordocname.aspx instead of .docx, and when i try to download this file it is getting a word document (obviously corrupted) as it is an aspx page document. Is there anyway I can download the doument direclty instead of the link page..
    – Flowerking
    Mar 28, 2012 at 12:44

The following code worked-(check the comments in the code)

    CamlQuery q = new CamlQuery();
    q.ViewXml = @"<View Scope='Recursive'>
    // This line did the trick!!! - "Test" is actually the name of document set I am trying to access
    q.FolderServerRelativeUrl = "/demo/Doc/Test";
    var returnlist = new List<string>();
    var items = list.GetItems(q);
    foreach (var item in items)
        //Now I can retrieve the files inside document set like this..
        var fileName = item.FieldValues["FileLeafRef"].ToString();



The more generic way of accomplishing what you want is to design the view through the web interface, and then inspect the resulting view XML, either through code or through a tool such as SharePoint Manager (http://spm.codeplex.com/).

This process will allow you to greatly speed up creating the view XML (because you do so through the web interface and verify that it is correct there) and it will give you all the options, not just filtering by content type.

You can view the outline of the process (although not explicitly for views) in a webcast I recorded for SP Saturday DC back in 2009. The method is still the same.



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.