Esempio n. 1
0
        private void NewResultsTreeName(TreeNode rootNode)
        {
            if (rootNode == null)
            {
                return;
            }
            if (!Directory.Exists((rootNode.Tag as Dictionary <string, string>)["Path"].ToString().Trim()))
            {
                return;
            }
            frmResultsTreeName pfrmResultsTreeName = new frmResultsTreeName();

            pfrmResultsTreeName.femText = "创建目录";
            pfrmResultsTreeName.LabText = "创建名称:";
            if (pfrmResultsTreeName.ShowDialog() == DialogResult.OK)
            {
                string strNewName = pfrmResultsTreeName.ResultsTreeName;
                if (strNewName == "")
                {
                    return;
                }
                string strPath = (rootNode.Tag as Dictionary <string, string>)["Path"].ToString().Trim() + "\\" + strNewName;
                if (!ModStringpro.IsSameTreeNode(rootNode, strNewName, strPath))
                {
                    TreeNode fileNode = new TreeNode(Path.GetFileName(strPath));  //创建文件夹类型新节点
                    Dictionary <string, string> pDicTag = new Dictionary <string, string>();
                    pDicTag.Add("Path", strPath);
                    pDicTag.Add("Type", "Folder");
                    fileNode.Tag              = pDicTag;
                    fileNode.ImageKey         = "关闭";
                    fileNode.SelectedImageKey = "关闭";
                    rootNode.Nodes.Add(fileNode);
                    fileNode.Expand();
                    Directory.CreateDirectory(strPath);
                }
            }
        }
Esempio n. 2
0
        private void ModifyResultsTreeName(TreeNode rootNode)
        {
            if (rootNode == null)
            {
                return;
            }
            if (!Directory.Exists((rootNode.Tag as Dictionary <string, string>)["Path"].ToString().Trim()))
            {
                return;
            }
            frmResultsTreeName pfrmResultsTreeName = new frmResultsTreeName();

            pfrmResultsTreeName.femText = "修改目录名称";
            pfrmResultsTreeName.LabText = "修改名称:";
            if (pfrmResultsTreeName.ShowDialog() == DialogResult.OK)
            {
                string strNewName = pfrmResultsTreeName.ResultsTreeName;
                if (strNewName == "")
                {
                    return;
                }
                string strPath = Path.GetDirectoryName((rootNode.Tag as Dictionary <string, string>)["Path"].ToString().Trim()) + "\\" + strNewName;
                if (!ModStringpro.IsSameTreeNode(rootNode.Parent, strNewName, strPath))
                {
                    try
                    {
                        Directory.Move((rootNode.Tag as Dictionary <string, string>)["Path"].ToString().Trim(), strPath);
                        rootNode.Text = strNewName;
                        Dictionary <string, string> pDicTag = new Dictionary <string, string>();
                        pDicTag.Add("Path", strPath);
                        pDicTag.Add("Type", "Folder");
                        rootNode.Tag = pDicTag;
                    }
                    catch { MessageBox.Show("修改失败!", "提示!", MessageBoxButtons.OK, MessageBoxIcon.Information); }
                }
            }
        }