public List <Folder> GetSubFolders(string ParentFullPath, byte ConstObjectType) { List <Folder> Result = new List <Folder>(); if (string.IsNullOrEmpty(ParentFullPath)) { ParentFullPath = "/"; } Func <string, string, string> GetDirectSub = (parent, sub) => { if (string.IsNullOrEmpty(sub) || string.IsNullOrEmpty(parent)) { return(null); } if (sub.Length <= parent.Length) { return(null); } string left = sub.Substring(parent.Length); string[] segments = left.Split('/'); foreach (var item in segments) { if (!string.IsNullOrEmpty(item)) { return(item); } } return(null); }; Action <string, string> AddNewFolder = (FolderSeg, FullPath) => { var lowerfolder = FolderSeg.ToLower(); if (Result.Find(o => o.Segment.ToLower() == lowerfolder) == null) { Folder subfolder = new Folder(ConstObjectType); subfolder.FullPath = FullPath; subfolder.Segment = FolderSeg; Result.Add(subfolder); } }; ParentFullPath = ParentFullPath.ToLower(); var subfolders = GetDescendantFolders(ParentFullPath, ConstObjectType); foreach (var item in subfolders) { string directsub = GetDirectSub(ParentFullPath, item.FullPath); if (!string.IsNullOrEmpty(directsub)) { string fullpath = CombineFolder(ParentFullPath, directsub); AddNewFolder(directsub, fullpath); } } PathTree tree = Cache.RouteTreeCache.RouteTree(this.SiteDb, ConstObjectType); var path = tree.FindPath(ParentFullPath, false); if (path == null) { return(Result); } foreach (var item in path.Children) { if (item.Value.RouteId == default(Guid) && PathHasSubObject(item.Value)) { string FullPath = CombineFolder(ParentFullPath, item.Value.segment); string Segment = item.Value.segment; AddNewFolder(Segment, FullPath); } } return(Result); }