public static bool HasParentChildRelation(this DirectoryInfo expectedParent, DirectoryInfo maybeOrphan)
{
for (var current = maybeOrphan; current != null; current = current.Parent)
{
if (expectedParent.FullName.Equals(current.FullName, StringComparison.InvariantCultureIgnoreCase))
{
return true;
}
}
return false;
}
}