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); }
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); }