Directory.CreateDirectory("new");
Directory.Move("old","new");
Directory.Delete("old",true);

解决方案 »

  1.   

    在事件Handles TreeView.AfterLabelEdit里加入更新文件夹的代码就可以了。
      

  2.   

    楼上的说的很对,问题就是我不知道该怎样加入更新文件夹的代码?
    private void tv_AfterLabelEdit(object sender, System.Windows.Forms.NodeLabelEditEventArgs e)
    {
    if (e.Label != null)
    {
    if(e.Label.Length > 0)
    {
    if (e.Label.IndexOfAny(new char[]{'@', '.', ',', '!'}) == -1)
    {
    e.Node.EndEdit(false);//结束编辑(不取消)
    }
    else
    {

    e.CancelEdit = true;//取消结束
    MessageBox.Show("违反文件夹命名规则\n" + 
    "不能在文件夹中出现的字符有: '@','.', ',', '!'", 
    "Node Label Edit");
    e.Node.BeginEdit();
    }
    }
    else
    {

    e.CancelEdit = true;
    MessageBox.Show("有问题的文件名.\n不能为空", 
    "Node Label Edit");
    e.Node.BeginEdit();
    }
    tv.LabelEdit = false;
    } }关键就是我不知道怎样得到更新后的节点名
      

  3.   

    还是我自己来回答吧!
    得到更新后的节点名:e.Label