是否有一个 Sharepoint API 可以立即获取站点内特定文件夹的嵌套目录结构?

Is there a Sharepoint API to get nested directory structure for a particular folder at once within a site?

是否有 Sharepoint API 可以一次性获取特定文件夹的 files/folders 的全部内容? 我不想递归地使用 GetFolderByServerRelativePath。

如果不想使用 GetFolderByServerRelativePath,您可以像这样将 CSOM 与 CAML 查询一起使用:

            string password = "pwd";
            string account = "user@Tenant.onmicrosoft.com";
            var secret = new SecureString();
            foreach (char c in password)
            {
                secret.AppendChar(c);
            }
            using (ClientContext ctx = new ClientContext("https://Tenant.sharepoint.com/sites/sitename"))
            {
                ctx.Credentials = new SharePointOnlineCredentials(account,secret);
                Web web = ctx.Web;
                ctx.Load(web);
                ctx.ExecuteQuery();
                List list = web.Lists.GetByTitle("Documents");
                ctx.Load(list);
                ctx.ExecuteQuery();
                Folder folder = web.GetFolderByServerRelativeUrl(web.ServerRelativeUrl + "/shared%20documents/");
                ctx.Load(folder);
                ctx.ExecuteQuery();

                CamlQuery camlQuery = new CamlQuery();
                camlQuery.ViewXml = @"<View Scope='RecursiveAll'>
                                     <Query>
                                     </Query>
                                 </View>";
                camlQuery.FolderServerRelativeUrl = folder.ServerRelativeUrl;
                ListItemCollection listItems = list.GetItems(camlQuery);
                ctx.Load(listItems);
                ctx.ExecuteQuery();
                foreach (var item in listItems)
                {
                    Console.WriteLine(item.FieldValues["FileRef"].ToString());
                }
            }

将 return 所有 folders/subfolders/files 在一起,希望这就是您所需要的。