What is the best way to get the url name of the list using CSOM.
For example, we have a list /sites/site/Lists/MyList/
We need "MyList".
We could get this, for example by parsing List.RootFolder.ServerRelativeUrl but is there a better way?
Example: how to get List Name by its Title:
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;
}
}