public void CreateNewFile(bool left) { string currentPath; if (left) { currentPath = CurrentPath1; } else { currentPath = CurrentPath2; } LabelForm labelForm = new LabelForm(0); labelForm.ShowDialog(); try { if (labelForm.done) { if (!File.Exists(currentPath + "\\" + labelForm.text)) { var file = File.Create(currentPath + "\\" + labelForm.text); director.CreateReport(currentPath + "\\" + labelForm.text); director.BuildReport(); reports.Add(director.GetReportItem()); file.Close(); } else { MessageBox.Show("Such a file already exists", "Error"); } } labelForm.Dispose(); } catch (Exception error) { labelForm.Dispose(); MessageBox.Show(error.Message.ToString(), "Error"); } }
public void Rename(ListView list, bool left) { string path = list.SelectedItems[0].Text; string currentPath; if (left) { currentPath = String.Format(@"{0}\\{1}", currentPath1, path); } else { currentPath = String.Format(@"{0}\\{1}", currentPath2, path); } LabelForm labelForm = new LabelForm(-1); labelForm.ShowDialog(); try { if (list.SelectedItems[0].ImageIndex == 0) { if (labelForm.done) { if (!Directory.Exists(currentPath + "\\" + labelForm.text)) { Folder folder = new Folder(currentPath); folder.Rename(labelForm.text); director.RenameReport(path, labelForm.text); director.BuildReport(); reports.Add(director.GetReportItem()); } else { MessageBox.Show("Such a folder is already exists", "Error"); } } } else { if (!File.Exists(currentPath + "\\" + labelForm.text)) { if (labelForm.done) { CommonFile commonFile = new CommonFile(currentPath); commonFile.Rename(labelForm.text); director.RenameReport(path, labelForm.text); director.BuildReport(); reports.Add(director.GetReportItem()); } labelForm.Dispose(); } else { MessageBox.Show("Such a file is already exists", "Error"); } } } catch (Exception error) { labelForm.Dispose(); MessageBox.Show(error.Message.ToString(), "Error"); } }