public TreeNode MakeHierarchy(ref IEnumerable <Folder> allFolders, ref Dictionary <string, TreeNode> existFoldersInTree, Folder folder, FolderType folderType, ref StringBuilder path) { TreeNode n = new TreeNode(); Folder fParent = new Folder(); foreach (Folder f in allFolders) { if (f.Id == folder.ParentId) { fParent = f; FolderType newFolderType = ClientRequests.GetFolderType(f.Type); n = MakeHierarchy(ref allFolders, ref existFoldersInTree, f, newFolderType, ref path); break; } } path.Append(folder.Name + "\\"); foreach (var temp in existFoldersInTree) { if (temp.Key == path.ToString()) { return(temp.Value); } } TreeNode newNode = new TreeNode(folder.Name); existFoldersInTree.Add(path.ToString(), newNode); int count = 0; try { count = ClientRequests.GetCountLetterInFolder(folder.Id); } catch (Exception ex) { NLogger.Logger.Trace(ex.ToString()); } if (count > 0) { newNode.Text += " " + count.ToString(); newNode.NodeFont = new Font(foldersTV.Font, FontStyle.Bold);; } if (folder.ParentId == Guid.Empty) { foldersTV.Nodes.Add(newNode); } else { n.Nodes.Add(newNode); } _currentPrivateFoldersInTree.Add(newNode.FullPath, folder); _currentPrivateFoldersTypeInTree.Add(newNode.FullPath, folderType); return(newNode); }