2 Replies Latest reply on Nov 25, 2009 12:18 PM by cmanhard

    Get Parent Paths

    Anwar005

      Hi,

       

      I need to find parent paths for particular element. Please help me with sample code.

       

      Thanks,

       

      Anwar

       

      untitled.gif

        • Re: Get Parent Paths
          hanyong

          Assuming you already have the AFElement representing the child element, we can find all the parent Elements that has a reference to the child element like:

          OSIsoft.AF.AFNamedCollection<AFElement> parents = child.Parents;

          foreach (AFElement p in parents)
          {
              Console.WriteLine(p.GetPath());
          }

          Hope this helps

            • Re: Get Parent Paths
              cmanhard

              string[] paths = myElement.GetPaths()
              works too and will return all paths.  For example, given this hierarchy:

               

              A\X\Y

               

              B->X\Y

               

              Y has one parent, but its parent, X, has two.

               

              Y.GetPaths() will return A\X\Y and B\X\Y, where as the first code would only produce A\X\Y