Ejemplo n.º 1
0
        private static void BuildDirectoryTree(CustomFolder rootDirectory)
        {
            try
            {
                var childDirectories = Directory.GetDirectories(rootDirectory.Name);
                foreach (string directory in childDirectories)
                {
                    rootDirectory.ChildDirectories.Add(new CustomFolder(directory));
                }
            }
            catch (UnauthorizedAccessException)
            {
                // Handle directories we dont have access to.
            }

            foreach (var childDirectory in rootDirectory.ChildDirectories)
            {
                CustomFolder.BuildDirectoryTree(childDirectory);
            }

            try
            {
                var files = Directory.GetFiles(rootDirectory.Name);
                foreach (string file in files)
                {
                    var info = new FileInfo(file);
                    rootDirectory.Files.Add(new CustomFile(file, info.Length));
                }
            }
            catch (UnauthorizedAccessException)
            {
                // Handle files we dont have access to.
            }
        }
Ejemplo n.º 2
0
        public static CustomFolder GetDirectory(string path)
        {
            var directory = new CustomFolder(path);

            CustomFolder.BuildDirectoryTree(directory);
            return(directory);
        }