Example #1
0
        private void btnAddFolder_Click(object sender, System.EventArgs e)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            fbd.Description = "Select tool folder";

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                ToolTreeNode newNode = ToolTreeNode.EncodeDirectory(fbd.SelectedPath);
                newNode.ImageIndex         = 1;
                newNode.SelectedImageIndex = 1;
                this.FilesTreeView.Nodes.Add(newNode);
            }
        }
Example #2
0
        public static ToolTreeNode EncodeDirectory(string path)
        {
            DirectoryInfo dinfo = new DirectoryInfo(path);

            if (dinfo.Exists)
            {
                ToolTreeNode ttn = new ToolTreeNode(path, ToolTreeNodeType.Directory);
                foreach (DirectoryInfo dir in dinfo.GetDirectories())
                {
                    ttn.Nodes.Add(ToolTreeNode.EncodeDirectory(dir.FullName));
                }
                foreach (FileInfo file in dinfo.GetFiles())
                {
                    ttn.Nodes.Add(new ToolTreeNode(file.FullName, ToolTreeNodeType.File));
                }

                return(ttn);
            }
            return(null);
        }