Namespaces
using Microsoft.SharePoint.Client;
Assemblies
Microsoft.SharePoint.Client.dll;
Microsoft.SharePoint.Client.RunTime.dll;
Code Snippet
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SharePoint.Client;
namespace CSOMSamples
{
class Program
{
static void Main(string[] args)
{
//// String Variable to store the siteURL
string siteURL = "http://c4968397007/";
//// Get the context for the SharePoint Site to access the data
ClientContext clientContext = new ClientContext(siteURL);
Web web = clientContext.Web;
//// Get the collection of navigation nodes from the top navigation bar
NavigationNodeCollection topNavigationColl = web.Navigation.TopNavigationBar;
clientContext.Load(topNavigationColl);
clientContext.ExecuteQuery();
//// Display all the node title which is available in the top navigation bar
foreach (NavigationNode node in topNavigationColl)
{
Console.WriteLine(node.Title);
}
Console.ReadLine();
}
}
}

吴翔 吴翔Posted Jun 4, 2018, 7:18 AM
Node can have child.