public void OnFileRename(object sender, MainFormEventArgs e) { View.RenameDeleteForm rd = new View.RenameDeleteForm(); if (rd.ShowDialog() == DialogResult.OK) { string newEntry = currentDirectory.FullName + @"\" + rd.txtBoxNewName.Text; IEntry oldEntry = FileFactory.CreateEntry(currentDirectory.FullName + @"\"); if (oldEntry is IDirectory) { InsertDirectory((IDirectory)oldEntry, newEntry); MyDirectory.Delete(oldEntry.FullName); } else { InsertFile((IFile)oldEntry, newEntry); MyFile.Delete(oldEntry.FullName); } navigationView.RefreshCurrentDirectoryEntries(); } /* string target = e.CurrentDir + e.Item; * if (MyDirectory.Exists(target)) * Directory.Move(target, e.CurrentDir + rd.txtBoxNewName.Text); * else * File.Move(target, e.CurrentDir + rd.txtBoxNewName.Text); * * rd.Close(); * rd = null; * OpenedDirectory(e.CurrentDir); * */ }
public void OnFileDelete(object sender, MainFormEventArgs e) { View.RenameDeleteForm rd = new View.RenameDeleteForm(); rd.lblAreUSure.Visible = true; rd.txtBoxNewName.Visible = false; rd.LblNewName.Visible = false; rd.lblAreUSure.Font = new Font("SanSerif", 12, FontStyle.Underline); if (rd.ShowDialog() == DialogResult.OK) { try { IEntry entry = FileFactory.CreateEntry(e.CurrentDir + @"\" + e.Item); if (entry is IDirectory) { MyDirectory.Delete(entry.FullName); } else { MyFile.Delete(entry.FullName); } navigationView.OnDeleted = true; navigationView.RefreshCurrentDirectoryEntries_1(); } catch (Exception ex) { throw new MyException("Отказано в доступе", ex); } } }