Esempio n. 1
0
        /// <summary>
        /// 构造树
        /// </summary>
        /// <param name="dirpath"></param>
        /// <param name="trv"></param>
        /// <returns></returns>
        public int ShowTree(string dirpath, FilesTreeView trv, List <string> fileList = null, bool showSub = true)
        {
            if (!Directory.Exists(dirpath))
            {
                return(-1);
            }
            ///构造树,并添加到ZTreeView 中
            trv.ClearAll();
            if (dirpath.EndsWith("\\"))
            {
                dirpath = dirpath.Remove(dirpath.Length - 1);
            }
            TreeNode root = new TreeNode(dirpath);

            trv.BuildPrjTree(root, dirpath, ".txt", null, fileList, showSub);
            trv.AddNode(root);
            root.Expand();
            return(0);
        }
Esempio n. 2
0
        public int ShowTree(string dirpath, FilesTreeView trv, TextBox tb, TextBox tbs)
        {
            FolderBrowserDialog dialog = new FolderBrowserDialog();

            dialog.ShowDialog();
            tb.Text = dialog.SelectedPath;
            if (!Directory.Exists(tb.Text))
            {
                return(-1);
            }
            ///构造树,并添加到ZTreeView 中
            trv.ClearAll();
            TreeNode root = new TreeNode(tb.Text);

            dialog.Dispose();
            trv.BuildPrjTree(root, tb.Text, ".txt", null);
            trv.AddNode(root);
            if (root.FirstNode == null) ///是个空目录
            {
                root.Nodes.Add("");
            }
            root.Expand();
            return(0);
        }