Risorse per professionisti IT >
Home page del forum
>
SharePoint - Development and Programming
>
Listing Folders and Subfolders in Sharepoint using Lists Web Service
Listing Folders and Subfolders in Sharepoint using Lists Web Service
- 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
Risposte
- Use QueryOptions (ViewAttributes as RecursiveAll) - "Query all folders and Sub folders" in CAML query builder
Please refer http://www.u2u.net/res/Tools/CamlQueryBuilder_WS.aspx
---
Rajesh (MCTS) My Blog- ModificatoRajesh.Sitaraman giovedì 2 luglio 2009 22.43
- Contrassegnato come rispostaOlorin.Maiar venerdì 3 luglio 2009 7.26
- Hi,
You should use the following values in the query:
queryOption.InnerXml = "<ViewAttributes Scope=\"RecursiveAll\" />";
spQuery.InnerXml = "<Where><Eq><FieldRef Name=\"FSObjType\" /><Value Type=\"Integer\">1</Value></Eq></Where>";
Peter- Contrassegnato come rispostaOlorin.Maiar venerdì 3 luglio 2009 7.26
Tutte le risposte
- Use QueryOptions (ViewAttributes as RecursiveAll) - "Query all folders and Sub folders" in CAML query builder
Please refer http://www.u2u.net/res/Tools/CamlQueryBuilder_WS.aspx
---
Rajesh (MCTS) My Blog- ModificatoRajesh.Sitaraman giovedì 2 luglio 2009 22.43
- Contrassegnato come rispostaOlorin.Maiar venerdì 3 luglio 2009 7.26
- Hi,
You should use the following values in the query:
queryOption.InnerXml = "<ViewAttributes Scope=\"RecursiveAll\" />";
spQuery.InnerXml = "<Where><Eq><FieldRef Name=\"FSObjType\" /><Value Type=\"Integer\">1</Value></Eq></Where>";
Peter- Contrassegnato come rispostaOlorin.Maiar venerdì 3 luglio 2009 7.26
- This works perfectly! Thanks.
Olorin - Hi Olorin,
I am happy that it works!
Peter

