1

I am trying to get the name of the document libraries of SharePoint online into a FolderCollection using the below code. But it looks like I am not getting the display name of "Documents" which is the default document library, instead I am getting "Shared Documents".

        using (var clientContext = new ClientContext("https://domain.sharepoint.com/sites/mSite"))
        {
            clientContext.Credentials = new SharePointOnlineCredentials(userName, sePassword);

            Web site = clientContext.Web;

            List list = clientContext.Web.Lists.GetByTitle("Documents");
            FolderCollection folderColl = clientContext.Web.Folders;
            clientContext.Load(folderColl);
            clientContext.ExecuteQuery();

            Folder currentFolder = null;

            foreach (Folder fol in folderColl)
            {
                Console.WriteLine(fol.Name); // not giving the "Documents"
                if (fol.Name == "Documents") // not executing this block since no "Documents"
                {
                    Console.WriteLine("Current Folder: " + currentFolder.Name);
                }
            }

        }

I know I can get them as a "list" with the name "Documents", but I need them in a FolderCollection. Is there any way to get the "Documents" instead of "Shared Documents" in the FolderCollection? Thanks!

1 Answer 1

1

When you treat document libraries as Folders, then the Document library's name is Shared Documents, not Documents.

Documents is merely a "Title" that can be different in different translations. The "Name" on the other hand never changes.

This is the URL of the default Document library. Notice how it says "Shared Documents"

https://contoso.sharepoint.com/sites/SiteA/Shared Documents/

The URL part of the Folder always matches the Name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.