Artemis.Engine.Utilities.DirectoryUtils.IsChildDirectoryOf C# (CSharp) Method

IsChildDirectoryOf() public static method

Determine if a given directory is a child directory of another.
public static IsChildDirectoryOf ( string parentDirectory, string childDirectory ) : bool
parentDirectory string
childDirectory string
return bool
        public static bool IsChildDirectoryOf(string parentDirectory, string childDirectory)
        {
            var childInfo  = new DirectoryInfo(childDirectory);
            var parentInfo = new DirectoryInfo(parentDirectory);

            while (childInfo.Parent != null)
            {
                if (childInfo.Parent.FullName == parentInfo.FullName)
                {
                    return true;
                }
                childInfo = childInfo.Parent;
            }
            return false;
        }