SharePoint Products TechCenter > SharePoint Products and Technologies Forums > SharePoint - Development and Programming > Listing Folders and Subfolders in Sharepoint using Lists Web Service
Ask a questionAsk a question
 

AnswerListing Folders and Subfolders in Sharepoint using Lists Web Service

  • Thursday, July 02, 2009 3:22 PMOlorin.Maiar Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi,

    I am using Sharepoint Lists Web Service to retrieve a list of folders within a Document Library. I use the following code:

    XmlDocument xmlDoc = new
     System.Xml.XmlDocument();
    XmlNode spViewFields = xmlDoc.CreateNode(XmlNodeType.Element, "ViewFields"
    , ""
    );
    XmlNode queryOption = xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions"
    , ""
    );
    XmlNode spQuery = xmlDoc.CreateNode(XmlNodeType.Element, "Query"
    , ""
    );
    
    spQuery.InnerXml = "<Where><Contains><FieldRef Name=\"
    FileRef\"/><Value Type=\"
    Text\">Docuemnt Library</Value></Contains></Where>"
    ;
    
    XmlNode ndListItems = spListsService.GetListItems("Document Library"
    , null
    , spQuery, spViewFields, null
    , queryOption);
    XmlNodeList oNodes = ndListItems.ChildNodes;
    

    However, this only returns folders within Document Library and not the Sub Folders. Is there a way to list the Sub Folders without calling the same code block recursively (using queryOptions.InnerText = <Folder>Document Library/SubFolderName</Folder>

    Olorin

Answers

All Replies