private void GetFolders() { this.assetsDirectory = Path.Combine(this.rootDirectory, "Assets"); this.projectSettingsDirectory = Path.Combine(this.rootDirectory, "ProjectSettings"); if (!Directory.Exists(this.projectSettingsDirectory)) { MessageBox.Show("project settings directory could not be found. Is this a Unity3D Project?"); return; } if (!Directory.Exists(this.assetsDirectory)) { MessageBox.Show("assets directory could not be found. Is this a Unity3D Project?"); return; } this.Folders.Add(new FolderSelectionItem("ProjectSettings", this.projectSettingsDirectory) { Selected = true }); string[] assetDirectories = Directory.GetDirectories(this.assetsDirectory); if (assetDirectories != null) { foreach (string assetDir in assetDirectories) { FolderSelectionItem rootItem = new FolderSelectionItem(Path.GetFileName(assetDir), assetDir); this.BuildDirectoryTree(rootItem); this.Folders.Add(rootItem); } } OnPropertyChanged("Folders"); }
private void BuildDirectoryTree(FolderSelectionItem parent) { string[] children = Directory.GetDirectories(parent.Path); if (children != null) { foreach (string directory in children) { FolderSelectionItem item = new FolderSelectionItem(Path.GetFileName(directory), directory); parent.AddChild(item); this.BuildDirectoryTree(item); } } }
private void Copy(FolderSelectionItem folder, string sourceDir) { string targetDir = Path.Combine(sourceDir, folder.Name); if (folder.Selected ?? false) { this.AddMessage(string.Format("Copying {0}.", folder.Path)); DirectoryHelper.Copy(folder.Path, targetDir, false); } foreach (FolderSelectionItem child in folder.Children) { this.Copy(child, targetDir); } }
public void AddChild(FolderSelectionItem item) { this.children.Add(item); item.PropertyChanged += Child_PropertyChanged; }