SharePoint wiki 分类获取所有的

Hi,

Regarding how to read all term set you can try the following code.

e.g.

    static void TermSetDemo(SPSite site)
    {
      TaxonomySession session = new TaxonomySession(site);
      // Get all the TermStores associated with the provided site.
      TermStoreCollection termStores = session.TermStores;    
      foreach (Group item in termStores[0].Groups)
      {
        Console.WriteLine(item.Name+":"+item.Id.ToString());
      }
      Console.WriteLine(termStores.Count);
      //get wiki site group guid
      //72174740-c695-4412-a87f-279cbf7f88cb
      Group wikiGroup = termStores[0].GetGroup(new Guid("72174740-c695-4412-a87f-279cbf7f88cb"));//wikiGroup.TermSets[0].Terms[0]
      foreach (TermSet set in wikiGroup.TermSets)
      {
        foreach (Term item in set.Terms)
        {
          Console.WriteLine(item.Name);
          Console.WriteLine("--------");
        }
        
      }

    }

For more information about the TermSet you can see the following document.

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.taxonomy.taxonomysession.aspx

原文地址:https://www.cnblogs.com/ahghy/p/2832660.html