Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Client Object Model - get "Title" of an Folder object

$
0
0

I'm using the C# client object model to retrieve recursively all doclibs and their folders from a web.

        private void LoadSubFolders(Microsoft.SharePoint.Client.Folder SPFolder, ICollection<Folder> folderCollection)
        {
            clientContext.Load(SPFolder, folder => folder.Folders
                .Include(f => f.Name, f => f.ServerRelativeUrl, f => f.ListItemAllFields, f => f.ListItemAllFields.DisplayName)
                .Where(f => f.Name != "Forms"));
            clientContext.ExecuteQuery();
            var currentFolder = new Folder { Name = SPFolder.Name, Path = SPFolder.ServerRelativeUrl };
            folderCollection.Add(currentFolder);

            foreach (var folder in SPFolder.Folders)
            {
                LoadSubFolders(folder, currentFolder.Folders);
            }
        }

When I call the "Name" property I get the internal name of the folder, which differs from the display name because of umlauts.
I need to get the "Title".

I tried this:

clientContext.Load(SPFolder,
f => f.Name,
f => f.ServerRelativeUrl,
f => f.ListItemAllFields,
f => f.ListItemAllFields.DisplayName); 
clientContext.ExecuteQuery();

But then I get the following message when accessing the DisplayName:

'SPFolder.ListItemAllFields.DisplayName' threw an exception of type 'Microsoft.SharePoint.Client.ServerObjectNullReferenceException'

See also this question:
Client Object Model get Display name of DocumentLibrary with umlauts

Thanks!


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>