// Invoked after the Renaming of the respective Node or Item took place private void TreeView_AfterLabelEdit(object sender, NodeLabelEditEventArgs e) { // Checks if Label is in correct layout if (CheckLabel(e.Label)) { bool remote = false; TextBox tb = tbLocalPath; string slash = "\\"; // If tvRemote if ((TreeView)sender == tvRemote) { remote = true; tb = tbRemotePath; slash = "/"; } string oldPath = tb.Text; // Add the new Label to the newPath string newPath = oldPath.Substring(0, oldPath.LastIndexOf(slash) + 1) + e.Label; // Rename Directory if (modify.Rename(oldPath, newPath, e.Label, remote)) { e.Node.Name = e.Label; e.Node.Tag = newPath; tb.Text = newPath; } // Stop editing without canceling the label change. e.Node.EndEdit(false); } else { /* Cancel the label edit action, inform the user, and * place the node in edit mode again. */ e.CancelEdit = true; if (e.Label != null) { e.Node.BeginEdit(); } } isRenaming = false; }