Search code examples
tridiontridion-2011

Get all folders of a publication using Core Service


Using Tridion Core Service how can we get existing folders of a particular publication. I am using SessionAwareCoreService2010Client class to create folders but could not locate in above class a proper method in core service to fetch list of all existing folders. Please answer with sample code.

Any help would be appreciated.


Solution

  • I can't test it at the moment, but it will be something like this:

    var rootFolderUri = "tcm:1-1-2";
    var filter = new OrganizationalItemItemsFilterData();
    filter.ItemTypes = new[] { ItemType.Folder };
    filter.Recursive = true;
    
    var listXml = client.GetListXml(rootFolderUri, filter);
    
    foreach (var itemElement in listXml.Descendants())
    {
        ...
    }