private void Rename(string path) { using (var form = new RenameForm()) { var editor = FindEditor(path); form.Path = path; if (form.ShowDialog(this) == DialogResult.OK && !path.Equals(form.Path, StringComparison.OrdinalIgnoreCase)) { editor?.Save(); string newPath = form.Path; if (Directory.Exists(path)) { Directory.Move(path, newPath); } else if (File.Exists(path)) { File.Move(path, newPath); } if (editor != null) { editor.Open(newPath); BeginInvoke(new Action(() => _projectControl.SelectFile(newPath))); } } } }
private void AddFile() { using (var form = new RenameForm()) { form.Text = "New File"; for (int i = 1; ; i++) { form.Path = Path.Combine(GetProjectItemDirectory(_projectControl.SelectedProjectItem), "JavaScript" + i + ".js"); if (!File.Exists(form.Path)) { break; } } if (form.ShowDialog(this) == DialogResult.OK) { File.WriteAllText(form.Path, ""); BeginInvoke(new Action <string>(p => OpenEditor(p)), form.Path); } } }