mercredi 4 février 2015

Get root,child,child,child and so on



how could i get my taxonomies from SharePoint Root has 3 folders, inside this folders i have more folders and inside the second folders i have more folders and so on,



class Program
{
static void Main(string[] args)
{

using (SPSite site = new SPSite(@"http://mysite.local/"))
{

SPWeb web = site.OpenWeb();

TaxonomySession taxonomySession = new TaxonomySession(site);
TermStore termStore = taxonomySession.TermStores[0];
Group group = termStore.Groups["MyGroup"];
TermSet termSet = group.TermSets["terms"];

foreach (Term termRoot in termSet.Terms)
{

foreach (Term subfolders in termRoot.Terms)
{



System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(@"C:\" + termRoot.Name);
if (di.Exists == false)
di.Create();
System.IO.DirectoryInfo dis = di.CreateSubdirectory(subfolders.Name);


}

}


}

}


}


Right now my code create root folders and subfolders, root1 and level1 of subdirectory, but i also want to get the taxonomies from my level1 subdirectory how could i do that? so i want to use create subdirectories 2 times?








0 commentaires:

Enregistrer un commentaire