Пример #1
0
        public override EtoDirectoryInfo GetSubDirectory(string subDirectory)
        {
            if (drive != null)
            {
                return(directory.GetSubDirectory(subDirectory));
            }

            var drives = DriveInfo.GetDrives();

            foreach (var childDrive in drives)
            {
                return(new EtoDriveInfo(childDrive));
            }
            return(null);
        }
Пример #2
0
        public static EtoDirectoryInfo GetDirectory(string path)
        {
            if (!Path.IsPathRooted(path))
            {
                path = Path.GetFullPath(path);
            }
            var pathRoot = Path.GetPathRoot(path);

            path = path.Substring(pathRoot.Length);
            string[] paths = path.Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);

            EtoDirectoryInfo di = new DiskDirectoryInfo(pathRoot);

            foreach (string dir in paths)
            {
                di = di.GetSubDirectory(dir);
                if (di == null)
                {
                    break;
                }
            }
            return(di);
        }