예제 #1
0
        public IFileElement GetElement(string path)
        {
            using (var pathEnumerator = new PathEnumerator(path)) {
                pathEnumerator.Reset();

                if (!pathEnumerator.MoveNext())
                {
                    throw new ArgumentException();
                }

                if (pathEnumerator.Current != this.Disk.Index.ToString())
                {
                    throw new ArgumentException();
                }

                var element = this.Root;
                while (pathEnumerator.MoveNext())
                {
                    if (!(element is IFolder))
                    {
                        throw new ArgumentException();
                    }

                    element = (element as IFolder) [pathEnumerator.Current];
                }

                return(element);
            }
        }
예제 #2
0
        public static string ExtractDiskIndex(string path)
        {
            using (var pathEnumerator = new PathEnumerator(path)) {
                pathEnumerator.Reset();

                if (!pathEnumerator.MoveNext())
                {
                    throw new ArgumentException();
                }

                return(pathEnumerator.Current);
            }
        }