public void UpdateFolderTree(IList <string> resourcePaths) { IFolder parent = RootFolder; foreach (string resourcePath in resourcePaths) { parent = RootFolder; string[] splitedFolders = resourcePath.Split(new string[] { ExplorerFactoryBase.PATH_SPLITER }, StringSplitOptions.RemoveEmptyEntries); string path = string.Empty; for (int i = 0; i < splitedFolders.Length; i++) { path += splitedFolders[i] + ExplorerFactoryBase.PATH_SPLITER; DirectoryInfo directory = new DirectoryInfo(path); if (directory.IsNull()) { break; } IFolder node = FindInFolder(directory.FullName, parent.Folders); if (node.IsNull()) { StaticLocalFolder currentFolder = new StaticLocalFolder(directory, parent); currentFolder.Folders.Clear(); parent.Folders.Add(currentFolder); parent = currentFolder; } else { parent = node; } } } }
private void ComposeRoutes(LocalRootFolder pcRoot) { if (pcRoot.IsNull()) { return; } IFolder parent = pcRoot; IList <IFolder> createdFolders = new List <IFolder>(); foreach (string folderPath in folderPaths) { //FindParent(folderPath, ref parents); parent = pcRoot; string[] splitedFolders = folderPath.Split(new string[] { PATH_SPLITER }, StringSplitOptions.RemoveEmptyEntries); string path = string.Empty; for (int i = 0; i < splitedFolders.Length; i++) { path += splitedFolders[i] + PATH_SPLITER; DirectoryInfo directory = new DirectoryInfo(path); if (directory.IsNull()) { break; } StaticLocalFolder currentFolder = createdFolders.FirstOrDefault(item => (0 == string.Compare(path, item.FullPath, true))) as StaticLocalFolder; if (currentFolder.IsNull()) { currentFolder = new StaticLocalFolder(directory, parent); currentFolder.Folders.Clear(); createdFolders.Add(currentFolder); parent.Folders.Add(currentFolder); } parent = currentFolder; } } }