private static ExTreeNode CreateDirectoryNode(DirectoryInfo directoryInfo, string[] excludedir, string[] excludefile) { var directoryNode = new ExTreeNode(directoryInfo.Name, directoryInfo.FullName, ProjectNodeType.Folder); foreach (var directory in directoryInfo.GetDirectories()) { if (excludedir == null) { directoryNode.Nodes.Add(CreateDirectoryNode(directory, excludedir, excludefile)); } else { if (!excludedir.Contains(directory.Name)) { directoryNode.Nodes.Add(CreateDirectoryNode(directory, excludedir, excludefile)); } } } foreach (var file in directoryInfo.GetFiles()) { if (excludefile == null) { directoryNode.Nodes.Add(new ExTreeNode(file.Name, file.FullName, ProjectNodeType.File)); } else { if (!excludefile.Contains(Path.GetExtension(file.FullName))) { directoryNode.Nodes.Add(new ExTreeNode(file.Name, file.FullName, ProjectNodeType.File)); } } } return(directoryNode); }
/// <summary> /// Add New File /// </summary> private void AddNewFile() { try { var path = projtree.SelectedNode as ExTreeNode; if (path != null && path.Type == ProjectNodeType.Folder) { using (var util = new FolderUtils()) { if (util.ShowDialog(this) != DialogResult.OK) { return; } var file = Path.Combine(path.Name, util.FileName); var node = new ExTreeNode(util.FileName, file, ProjectNodeType.File); File.WriteAllText(file, ""); projtree.SelectedNode.Nodes.Add(node); } } } catch (Exception ex) { MessageBox.Show("There was an Error : " + ex.Message, "Project Manager", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
/// <summary> /// Adds a New Folder to existing folder /// </summary> private void AddNewFolder() { var path = projtree.SelectedNode as ExTreeNode; if (path != null && path.Type == ProjectNodeType.Folder) { using (var util = new FolderUtils()) { if (util.ShowDialog(this) != DialogResult.OK) { return; } var dir = Path.Combine(path.Name, util.FileName); var node = new ExTreeNode(util.FileName, dir, ProjectNodeType.Folder); Directory.CreateDirectory(dir); projtree.SelectedNode.Nodes.Add(node); } } }
/// <summary> /// Rename /// </summary> /// <param name="path"></param> /// <param name="newpath"></param> /// <param name="node"></param> private static void RenameFile(string path, string newpath, ExTreeNode node) { File.Move(path, newpath); node.Name = newpath; }
/// <summary> /// Renames Directory /// </summary> /// <param name="path"></param> /// <param name="newpath"></param> /// <param name="node"></param> private void RenameDirectory(string path, string newpath, ExTreeNode node) { Directory.Move(path, newpath); node.Text = Path.GetFileName(newpath); node.Name = newpath; }
/// <summary> /// Renames Directory /// </summary> /// <param name="path"></param> /// <param name="newpath"></param> /// <param name="node"></param> private void RenameDirectory(string path, string newpath, ExTreeNode node) { Directory.Move(path, newpath); node.Text = Path.GetFileName(newpath); node.Name = newpath; }
/// <summary> /// Adds a New Folder to existing folder /// </summary> private void AddNewFolder() { var path = projtree.SelectedNode as ExTreeNode; if (path != null && path.Type == ProjectNodeType.Folder) { using (var util = new FolderUtils()) { if (util.ShowDialog(this) != DialogResult.OK) return; var dir = Path.Combine(path.Name, util.FileName); var node = new ExTreeNode(util.FileName, dir, ProjectNodeType.Folder); Directory.CreateDirectory(dir); projtree.SelectedNode.Nodes.Add(node); } } }
/// <summary> /// Add New File /// </summary> private void AddNewFile() { try { var path = projtree.SelectedNode as ExTreeNode; if (path != null && path.Type == ProjectNodeType.Folder) { using (var util = new FolderUtils()) { if (util.ShowDialog(this) != DialogResult.OK) return; var file = Path.Combine(path.Name, util.FileName); var node = new ExTreeNode(util.FileName, file, ProjectNodeType.File); File.WriteAllText(file, ""); projtree.SelectedNode.Nodes.Add(node); } } } catch (Exception ex) { MessageBox.Show("There was an Error : " + ex.Message, "Project Manager", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
/// <summary> /// Rename /// </summary> /// <param name="path"></param> /// <param name="newpath"></param> /// <param name="node"></param> private static void RenameFile(string path, string newpath, ExTreeNode node) { File.Move(path, newpath); node.Name = newpath; }
private static ExTreeNode CreateDirectoryNode(DirectoryInfo directoryInfo, string[] excludedir, string[] excludefile) { var directoryNode = new ExTreeNode(directoryInfo.Name, directoryInfo.FullName, ProjectNodeType.Folder); foreach (var directory in directoryInfo.GetDirectories()) { if (excludedir == null) directoryNode.Nodes.Add(CreateDirectoryNode(directory, excludedir, excludefile)); else { if (!excludedir.Contains(directory.Name)) directoryNode.Nodes.Add(CreateDirectoryNode(directory, excludedir, excludefile)); } } foreach (var file in directoryInfo.GetFiles()) { if (excludefile == null) directoryNode.Nodes.Add(new ExTreeNode(file.Name, file.FullName, ProjectNodeType.File)); else { if (!excludefile.Contains(Path.GetExtension(file.FullName))) directoryNode.Nodes.Add(new ExTreeNode(file.Name, file.FullName, ProjectNodeType.File)); } } return directoryNode; }