SharePoint GetFolderByServerRelativeUrl is a method in the SharePoint Object Model that retrieves a folder based on its server-relative URL. \u000A\u000ASyntax:\u000A\u000Apublic Folder GetFolderByServerRelativeUrl(string serverRelativeUrl)\u000A\u000A\u000AParameters:\u000A- serverRelativeUrl (string): The server-relative URL of the folder to retrieve. This should be in the format "/sites/SiteName/LibraryName/FolderName".\u000A\u000AReturn Value:\u000A- Folder: The folder object that represents the retrieved folder.\u000A\u000AExample Usage:\u000Acsharp\u000Ausing Microsoft.SharePoint.Client;\u000A\u000A// ...\u000A\u000Astring siteUrl = "https://your-site-url";\u000Astring folderUrl = "/sites/SiteName/LibraryName/FolderName";\u000A\u000Ausing (ClientContext context = new ClientContext(siteUrl))\u000A{\u000A Web web = context.Web;\u000AFolder folder = web.GetFolderByServerRelativeUrl(folderUrl);\u000A \u000A context.Load(folder);\u000A context.ExecuteQuery();\u000A\u000A Console.WriteLine("Folder Name: " + folder.Name);\u000A Console.WriteLine("Folder URL: " + folder.ServerRelativeUrl);\u000A}\u000A\u000A\u000AIn the example above, we first create a ClientContext object with the URL of the SharePoint site. Then, we use the GetFolderByServerRelativeUrl method of the Web object to retrieve the folder specified by the server-relative URL. Finally, we load the folder object and execute the query to retrieve its properties.

SharePoint GetFolderByServerRelativeUrl: Retrieve Folder by URL - C# Example

原文地址: https://www.cveoy.top/t/topic/p79Z 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录