Domanda

Qual è il modo migliore per ottenere il nome dell'URL dell'elenco usando CSOM.

Ad esempio, abbiamo una lista / siti / sito / elenchi / Mylist /

Abbiamo bisogno di "Mylist".

Potremmo ottenere questo, ad esempio per Parsing List.rootfolderder.serverrelativerl ma c'è un modo migliore?

È stato utile?

Soluzione

Try:

List.RootFolder.Name

It should work for both lists and document libraries.

Altri suggerimenti

Esempio: come ottenere il nome dell'elenco per il suo titolo:

public static string ResolveListUrl(string url, ICredentials credentials, string listTitle)
{
    using (var clientContext = new ClientContext(url))
    {
        clientContext.Credentials = credentials;

        var list = clientContext.Web.Lists.GetByTitle(listTitle);
        clientContext.Load(list.RootFolder);
        clientContext.ExecuteQuery();
        return list.RootFolder.Name;
    }
}
.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top