Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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);
clientccontext.Load(items);
clientccontext.ExecuteQuery();

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.

share|improve this question
add comment

3 Answers 3

up vote 1 down vote accepted

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.

share|improve this answer
    
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 '12 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 '12 at 12:44
add comment

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

    CamlQuery q = new CamlQuery();
    q.ViewXml = @"<View Scope='Recursive'>
                            <Query>
                            </Query>
                        </View>";
    // 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);
    cc.Load(items);
    cc.ExecuteQuery();
    foreach (var item in items)
    {
        //Now I can retrieve the files inside document set like this..
        var fileName = item.FieldValues["FileLeafRef"].ToString();

        returnlist.Add(fileName);
    }
share|improve this answer
add comment

Flowerking,

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.

http://vimeo.com/4340994

.b

share|improve this answer
add comment

Your Answer

 
discard

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.