private void GetDirectories(DirectoryInfo[] subDirs, ProjectFolderNode nodeToAddTo, FitProj p) { ProjectFolderNode aNode; DirectoryInfo[] subSubDirs; foreach (DirectoryInfo subDir in subDirs) { aNode = new ProjectFolderNode() { Text = subDir.Name }; aNode.Tag = subDir; subSubDirs = subDir.GetDirectories(); if (subSubDirs.Length != 0) { GetDirectories(subSubDirs, aNode, p); } GetFiles(subDir, aNode, p); nodeToAddTo.Nodes.Add(aNode); } }
public void AddFolder() { int i = 0; foreach (TreeNode n in this.Nodes) { if (n.Text == $"NewFolder{i}") { i++; } else { break; } } string path = ""; if (this is ProjectNode) { path = Path.Combine(Path.GetDirectoryName((((FileInfo)this.Tag).FullName)), $"NewFolder{i}"); } else { path = Path.Combine((((DirectoryInfo)this.Tag).FullName), $"NewFolder{i}"); } ProjectNode.Project.AddFolder(path); Directory.CreateDirectory(path); var node = new ProjectFolderNode() { Tag = new DirectoryInfo(path) }; node.Text = $"NewFolder{i}"; Nodes.Add(node); node.EnsureVisible(); node.BeginEdit(); }
private void GetFiles(DirectoryInfo dir, ProjectFolderNode nodeToAddTo, FitProj p) { foreach (var fileinfo in dir.GetFiles()) { if (fileinfo.Name.EndsWith(".fitproj", StringComparison.InvariantCultureIgnoreCase)) { break; } var child = new ProjectFileNode() { Text = fileinfo.Name }; child.Tag = fileinfo; foreach (var f in p.IncludedFiles) { if (fileinfo.FullName.Contains(f.RelativePath)) { nodeToAddTo.Nodes.Add(child); break; } } } }