Reputation: 31
i rename the treeview treenode in application using keyword F2. After Renaming this, this name change should happen in the directory also..How do i know i have done edited name and it is changed and where can i call change directory name method.
private void treeView_project_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyValue == (char)Keys.F2)
{
treeView_Project.SelectedNode.BeginEdit();
//here it is editing the treenode once it is done user should rename the folder also in the drive
}
}
Upvotes: 2
Views: 1009
Reputation: 1277
If you know the path of the directory, you can rename the directory with these lines:
try
{
DirectoryInfo di = new DirectoryInfo(path);
di.MoveTo(di.Parent + "\\" + newName);
}
catch (Exception e)
{
//Changing directory name failed
}
Upvotes: 1