public void Rename(FileModel fileModel) { RenameViewModel viewModel = ViewModelSource.Create <RenameViewModel>(); viewModel.Name = fileModel.Name; viewModel.Extension = fileModel.Extension; viewModel.DateCreated = fileModel.DateCreated; viewModel.DateModified = fileModel.DateModified; viewModel.DateAccessed = fileModel.DateAccessed; viewModel.ShowPatternButtons = true; viewModel.ShowAdvancedOptions = true; viewModel.Parent = fileModel.ParentName.RemoveInvalidFileNameCharacters(); if (String.IsNullOrEmpty(viewModel.Parent)) { viewModel.Parent = fileModel.ParentPath.RemoveInvalidFileNameCharacters(); } MessageResult result = DialogService.ShowDialog(MessageButton.OKCancel, Properties.Resources.Rename, "RenameView", viewModel); if (result == MessageResult.OK) { string newName = viewModel.Name.Trim() + viewModel.Extension; if (newName != fileModel.FullName) { Utilities.RenameFile(fileModel.FullPath, newName); } if (fileModel.DateCreated != viewModel.DateCreated) { Utilities.SetCreationTime(fileModel.FullPath, viewModel.DateCreated); } if (fileModel.DateModified != viewModel.DateModified) { Utilities.SetLastWriteTime(fileModel.FullPath, viewModel.DateModified); } if (fileModel.DateAccessed != viewModel.DateAccessed) { Utilities.SetLastAccessTime(fileModel.FullPath, viewModel.DateAccessed); } FileModel.FromPath(fileModel.FullPath); } }
public void CreateNewFolder() { RenameViewModel viewModel = ViewModelSource.Create <RenameViewModel>(); viewModel.Name = Properties.Resources.NewFolder; viewModel.Parent = CurrentFolder.Name; if (String.IsNullOrEmpty(viewModel.Parent)) { viewModel.Parent = CurrentFolder.FullPath.Replace(":", ""); } MessageResult result = DialogService.ShowDialog(MessageButton.OKCancel, Properties.Resources.NewFolder, "RenameView", viewModel); if (result == MessageResult.OK) { Utilities.CreateFolder(CurrentFolder.FullPath, viewModel.Name); } }