In an application I'm working on, I'm interacting with SharePoint (2010) via the .NET Client-Side Object Model, and am trying to account for a large number of possible configurations of document libraries.

In the instance that a document library has content approval enabled, if I create a new Folder object, the approval status applies to this ListItem as well:

Newly Created Folder

How can I get a reference to the ListItem that is the newly created Folder object?

I need to set this value to SPModerationStatusType.Approved programmatically when I create a new folder, but can't find a way to modify the fields of the ListItem given that I only have a Folder object.

I want to get a ListItem object so I can do something like this:

Working With Content Approval / Moderation In CSOM


For SharePoint 2013, they've apparently taken this into consideration and have added a Folder.ListItemAllFields property which would be exactly what I need here, but this property is unavailable to the 2010 CSOM.

  • can you please put the entire code.. as for me the query is showing null. I want to edit the _approval status as approved for folders/ subfolder recursivly.can you please help.
    – user15798
    Commented Mar 21, 2013 at 13:06

1 Answer 1


I solved this by using a CamlQuery directly after creation to return folders with the same name as a ListItemCollection:

SP.CamlQuery query = new SP.CamlQuery();
query.ViewXml = "<View Scope='RecursiveAll'>" +
                  "<Query>" +
                    "<Where>" +
                      "<And>" +
                        "<Eq>" +
                          "<FieldRef Name='ContentType'/>" +
                          "<Value Type='Text'>Folder</Value>" +
                        "</Eq>" +
                        "<Eq>" +
                          "<FieldRef Name='FileLeafRef'/>" +
                          "<Value Type='Text'>" + subFolderName + "</Value>" +
                        "</Eq>" +
                      "</And>" +
                    "</Where>" +
                  "</Query>" +

SP.ListItemCollection items = list.GetItems(query);

With a little validation of the item I can set the property as I need.

  • Thanks, I would like to recommend using of "FileRef" (folder directory) instead of "FileLeafRef" (folder name).
    – Warlock
    Commented Mar 4, 2013 at 18:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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