/***改名***/#region/***改名***/
/**//// <summary>
/// 重命名文件夹
/// </summary>
public void Rename()
{
TreeNode node = this._tree.SelectedNode;
DirectoryInfo dirObj = this.GetDirObj(node);
if(dirObj.Attributes.ToString().IndexOf("ReadOnly") != -1)
return;
inReNameMode = true;
this.RenameSelectedNode();
}
#endregion
/**//// <summary>
/// 重命名文件夹
/// </summary>
public void Rename()
{
TreeNode node = this._tree.SelectedNode;
DirectoryInfo dirObj = this.GetDirObj(node);
if(dirObj.Attributes.ToString().IndexOf("ReadOnly") != -1)
return;
inReNameMode = true;
this.RenameSelectedNode();
}
#endregion
/***LabelEdit***/#region/***LabelEdit***/
private bool inReNameMode = false;
private void _tree_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
{
TreeNode node = this._tree.SelectedNode;
if(inReNameMode)
{
if(e.Label == null)
return;
string newPath = this.GetNodePathStr(node.Parent) + e.Label;
DirectoryInfo dirObj = this.GetDirObj(node);
try
{
dirObj.MoveTo(newPath);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
inReNameMode = false;
}
}
}
#endregion
2)private bool inReNameMode = false;
private void _tree_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
{
TreeNode node = this._tree.SelectedNode;
if(inReNameMode)
{
if(e.Label == null)
return;
string newPath = this.GetNodePathStr(node.Parent) + e.Label;
DirectoryInfo dirObj = this.GetDirObj(node);
try
{
dirObj.MoveTo(newPath);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
inReNameMode = false;
}
}
}
#endregion
/***重命名***/#region/***重命名***/
//重命名
private void menuItem2_Click(object sender, System.EventArgs e)
{
oldFolder=this.tv_Path.SelectedNode.Text;
this.tv_Path.LabelEdit=true;
this.tv_Path.SelectedNode.BeginEdit();
}
#endregion
private void tv_Path_AfterLabelEdit(object sender, System.Windows.Forms.NodeLabelEditEventArgs e)//重命名
private void menuItem2_Click(object sender, System.EventArgs e)
{
oldFolder=this.tv_Path.SelectedNode.Text;
this.tv_Path.LabelEdit=true;
this.tv_Path.SelectedNode.BeginEdit();
}
#endregion
{
……
}