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();
{
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
Post a Comment