SharePoint: How to retrieve the list of item from the Sub folders by using Lists.asmx web service

Unfortunately SPS SDK doesn’t provide sample to get the details from the subfolder. I have compiled a sample code snippet to achieve it. Here you go for the code.

 

      localhost.Lists listService = new localhost.Lists();

            listService.Credentials = System.Net.CredentialCache.DefaultCredentials;

            //url and folder name hard coded - modify it as per your requirement.

            listService.Url = "https://karthickmain:9090/sites/a1/_vti_bin/lists.asmx";

            XmlDocument xmlDoc = new System.Xml.XmlDocument();

            //Create query options node

            XmlNode ndQueryOptions = xmlDoc.CreateNode(XmlNodeType.Element,"QueryOptions","");

            //Specify the folder name

            ndQueryOptions.InnerXml = "<Folder>SourceDL/Folder1</Folder>";

            //get the items

            XmlNode ndListItems = listService.GetListItems("SourceDL", null, null, null, null, ndQueryOptions);

            //display the node

            MessageBox.Show(ndListItems.OuterXml);