How to enumerate the items inside a SharePoint Document Library folder

In my previous blog I have included the information for downloading files from a document library, using that code we can't download the files from a folder inside the document library, if it has. Below I am giving a work around for iterating the items inside the folder. Once if we get the files inside the folder and using the URL of that file we can download the files to our local drive using HTTPRequest and HTTPResponse & FileStream classes mentioned in my previous article.

Below I am giving the URL of the blog which will provide the information on how to download the files from a SharePoint document library.

We can implement this functionality using a SharePoint web service called SiteData.asmx which is available in the /_vti_bin/ location of the SharePoint site. Using EnumerateFolder web method we can enumerate the files or folders inside the folder in a document library. You can enhance this code for doing the enumeration more than one level by implementing your own logic. This sample code snippet of a .Net console application will just enumerate a folder and it will display the URL of the files or folders inside that folder.

First you need to add a web reference to the SiteData.asmx web service to your application. After that you have to create the instance of service class for getting the web methods.


siteData.SiteData objSiteDataService = new SiteData();

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

objSiteDataService.Url = "http://localhost:34028/sites/TestSite/_vti_bin/sitedata.asmx"; // change the URL to your sharepoint site

siteData._sFPUrl[] enArray;

objSiteDataService.EnumerateFolder("http://localhost:34028/sites/TestSite/TestT/TM", out enArray); // here I hard coded the URL of the folder in "TestT" document library

foreach(siteData._sFPUrl en in enArray)







Comments (2)

  1. Akil says:

    I have coded in java, code are as under but i am getting a null value instead of folders info.

     SiteData SiteData = new SiteData();

                    String sharePointSourceURL = "Check/files";

                   Holder<Long> enumerateFolderResult = new Holder<Long>();

                   Holder<ArrayOfSFPUrl> vUrls = new Holder<ArrayOfSFPUrl>();

                   SiteData.getSiteDataSoap().enumerateFolder(sharePointSourceURL, enumerateFolderResult, vUrls);



                   if(null != vUrls.value){

                           for(SFPUrl url : vUrls.value.getSFPUrl()){






    Check/files has all the files and folder. Please let me know what i am doing wrong.

                           System.out.println("Folder is empty");


  2. Adhikari says:

    @Akil, i'm also getting the same problem…………However, when i implement it using SOAP UI, it works perfectly……………….. Is the problem with JAX-WS? If you have fixed the problem, i would appreciate your help.

    I've also included the authentication using binding, if that seems to be an issue.

Skip to main content