Partager via


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);

Comments

  • Anonymous
    September 10, 2007
    The comment has been removed
  • Anonymous
    September 10, 2011
    Hi, I would like to get the count of items in subfolders in a document library and so I used the above code but I get the count of items in the root folder so how could I get the items in a certain folder. Thanks in advance.