private Directorys MakeTree(string root) { // нужно заполнить дерево. (пока возвращает все.) Directorys curDir = new Directorys(); curDir.path = root; curDir.files = new List <string>(); curDir.filesRights = new List <string[]>(); WatchingFileRights wfr = new WatchingFileRights(); string[] curFiles = Directory.GetFiles(root, "*txt"); for (int i = 0; i < curFiles.Length; i++) { if (wfr.FileAllowedForUser(currentUser, curFiles[i])) { curDir.files.Add(curFiles[i]); } string[] tmp = wfr.AllowedUserList(curFiles[i]); if (tmp != null) { string[] tmp2 = new string[tmp.Length + 1]; tmp2[0] = curFiles[i]; for (int a = 0; a < tmp.Length; a++) { tmp2[a + 1] = tmp[a]; } // тут проверим доступен ли этот файл текущему пользователю if (wfr.FileAllowedForUser(currentUser, tmp2[0])) { curDir.filesRights.Add(tmp2); } } } string[] curDirs = Directory.GetDirectories(root); curDir.subdirectorys = new List <Directorys>(); for (int i = 0; i < curDirs.Length; i++) { curDir.subdirectorys.Add(MakeTree(curDirs[i])); } return(curDir); }