This is the query I use to get only Powerpoint files from a list:

        Guid id = new Guid(reportLibrary); // ID for the Report library. Needs to be configured at the beginning of the class.
        List sharedDocumentsList = clientContext.Web.Lists.GetById(id);
        CamlQuery camlQuery = new CamlQuery();
        camlQuery.ViewXml = "<Where><Eq><FieldRef Name='FileExtension'><Value Type='text'>ppt</Value></FieldRef></Eq></Where>";
        ListItemCollection listItems = sharedDocumentsList.GetItems(camlQuery);

I got the query from this question: Selecting only PowerPoint files in a CAML query Sadly, the query does not do what I would expect. It still returns all the files in the list, which results in a crash further down, since the programm I wrote only expects Powerpoint files. Am I doing something wrong? Do I have to execute the query differently?

  • You are missing <View><Query> around your CAML (also add </Query></View> at the end Oct 12, 2016 at 11:49

2 Answers 2


You are missing <View> and <Query> tags in ViewXml. Your ViewXml will be like:

camlQuery.ViewXml = "<View><Query><Where><Eq><FieldRef Name='FileExtension'><Value Type='Text'>ppt</Value></FieldRef></Eq></Where><Query><View>";

I would use DocIcon to filter results, make sure to support both ppt and pptx file formats, and use some value for RowLimit.

            <FieldRef Name='DocIcon' />
            <Value Type='Computed'>pptx</Value>
            <FieldRef Name='DocIcon' />
            <Value Type='Computed'>ppt</Value>

See also:

How to: Retrieve List Items

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.