Share via


Navigating to the Parent Object

DirectoryEntry also has a Parent property used to navigate from the object to which you are connected to its parent object.

The following code example shows how to navigate to the parent object.

[Visual Basic .NET]

Dim parent As DirectoryEntry = entry.Parent
 Console.WriteLine(parent.Name)

[C#]

DirectoryEntry parent = ent.Parent;
Console.WriteLine(parent.Name);