コード例 #1
0
        public List <UserDirectoryClass> MakingDirrectoryTree(string root = null)
        {
            if (root == null)
            {
                root = rootItitial;
                if (!Directory.Exists(root + NameBasket))
                {
                    Directory.CreateDirectory(root + NameBasket);
                }
            }

            DirectoryInfo             dir  = new DirectoryInfo(root);
            List <UserDirectoryClass> list = new List <UserDirectoryClass>();

            foreach (var item in dir.GetDirectories())
            {
                UserDirectoryClass userDir = new UserDirectoryClass();
                userDir.Name     = item.Name.ToUpper();
                userDir.FullName = item.FullName;
                list.Add(userDir);
                userDir.Children.AddRange(MakingDirrectoryTree(item.FullName));
            }

            foreach (var item in dir.GetFiles())
            {
                UserDirectoryClass userDir = new UserDirectoryClass();
                userDir.Name     = item.Name;
                userDir.FullName = item.FullName;
                list.Add(userDir);
            }
            return(list);
        }
コード例 #2
0
        public List <UserDirectoryClass> MakingDirrectoryTree(string root)
        {
            DirectoryInfo             dir  = new DirectoryInfo(root);
            List <UserDirectoryClass> list = new List <UserDirectoryClass>();

            foreach (var item in dir.GetDirectories())
            {
                UserDirectoryClass userDir = new UserDirectoryClass();
                userDir.Name     = item.Name.ToUpper();
                userDir.FullName = item.FullName;
                list.Add(userDir);
                userDir.Children.AddRange(MakingDirrectoryTree(item.FullName));
            }

            foreach (var item in dir.GetFiles())
            {
                UserDirectoryClass userDir = new UserDirectoryClass();
                userDir.Name     = item.Name;
                userDir.FullName = item.FullName;
                list.Add(userDir);
            }
            return(list);
        }