Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void Rename(ListView list, bool left)
- {
- string path = list.SelectedItems[0].Text;
- string currentPath;
- if (left)
- currentPath = string.Format(@"{0}\\{1}", CurrentPathLeft, path);
- else
- currentPath = string.Format(@"{0}\\{1}", CurrentPathRight, path);
- LabelForm labelForm = new LabelForm(LabelForm.FormType.Uncategorized);
- 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);
- }
- else
- {
- MessageBox.Show("Folder already exists", "Error");
- }
- }
- }
- else
- {
- if (!File.Exists(currentPath + "\\" + labelForm.text))
- {
- if (labelForm.done)
- {
- GenericFile commonFile = new GenericFile(currentPath);
- commonFile.Rename(labelForm.text);
- }
- labelForm.Dispose();
- }
- else
- {
- MessageBox.Show("File already exists", "Error");
- }
- }
- }
- catch (Exception error)
- {
- labelForm.Dispose();
- MessageBox.Show(error.Message.ToString(), "Error");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement