Get the folder name which is in document library using csom
How to get the name of the folder names which are in document library in sharepoint using csom code.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Manpreet SinghRank #15 · 50.7K reputationPosted Jul 13, 2015, 8:39 AM EDT
SP.CamlQuery.createAllItemsQuery().using (var clientContext = spContext.CreateUserClientContextForSPHost()) { List list = clientContext.Web.Lists.GetByTitle("Documents"); CamlQuery camlQuery = new CamlQuery(); camlQuery.ViewXml = @""; Folder ff = list.RootFolder; FolderCollection fcol = list.RootFolder.Folders; List lstFile = new List(); clientContext.Load(list.RootFolder.Folders); clientContext.Load(ff); clientContext.Load(list); clientContext.Load(list.RootFolder); clientContext.Load(list.RootFolder.Folders); clientContext.Load(list.RootFolder.Files); clientContext.ExecuteQuery(); Response.Write("Root : " + ff.Name+"\r\n"); Response.Write( " ItemCount : " + ff.ItemCount.ToString() ); Response.Write( " Folder Count : " + ff.Folders.Count.ToString() ); Response.Write( " File Count : " + ff.Files.Count.ToString()); Response.Write( " URL : " + ff.ServerRelativeUrl ); foreach (Folder f in fcol) { if (f.Name == "Testing") { clientContext.Load(f.Files); clientContext.ExecuteQuery(); FileCollection fileCol = f.Files; foreach (File file in fileCol) { lstFile.Add(file.Name); Response.Write(" File Name : " + file.Name); } } } }satya repaka47 reputationPosted Jul 14, 2015, 4:45 AM EDT
Manpreet SinghRank #15 · 50.7K reputationPosted Jul 14, 2015, 7:47 AM EDT
satya repaka47 reputationPosted Jul 14, 2015, 10:03 PM EDT
Ravin SinghRank #2,648 · 525 reputationPosted Jul 22, 2015, 12:52 AM EDT
Manpreet SinghRank #15 · 50.7K reputationPosted Jul 31, 2015, 1:30 PM EDT