Get folder names using share point client object model.

Add the Dll reference "Microsoft.SharePoint.Client.dll" and "Microsoft.SharePoint.Client.RunTime.dll" to the project.

name space reference "using SP = Microsoft.SharePoint.Client;"

using (SP.ClientContext ctx = new SP.ClientContext(ProjectURL))
            {
                SP.Web web = ctx.Web;
                ctx.Load(web);
                SP.List docList = web.Lists.GetByTitle("Shared Documents");
                ctx.Load(docList.RootFolder.Folders);
                SP.FolderCollection collection = docList.RootFolder.Folders;
                ctx.Load(collection);
                ctx.ExecuteQuery(); 

                foreach (SP.Folder folders in collection)
                {
                    string filderName = folders.Name;
                }
            }



-- folders.Name will give the folder name.

Comments

Popular posts from this blog

Sending email using Powershell script

Convert List Collection to DataTable using C#

Difference Between Site Template and Site Definition