private async void MoveAlbum() { if (_albumToMove == null) { MessageBox.Show("Please select album to move"); return; } await _albumService.MoveAlbumToPerformerAsync(_albumToMove.Id, SelectedPerformer.Id); var album = Mapper.Map <Album>(_albumToMove); var performer = Mapper.Map <Performer>(_selectedPerformer); _albumToMovePerformer.Albums.Remove(_albumToMove); _albumToMovePerformer.UpdateAlbumCollectionRate(_rateCalculator); _albumToMove.Performer = performer; _albumToMove.LocateImagePath(); if (MessageBox.Show("Do you want to move all corresponding files as well?", "Confirmation", MessageBoxButton.YesNoCancel) != MessageBoxResult.Yes) { await InsertAlbumToCollectionAsync(_albumToMove); return; } var pathlist = FileLocator.MakePerformerImagePathlist(performer); var path = string.Empty; if (pathlist.Count == 1) { path = Path.GetDirectoryName(pathlist.First()); } else { var choice = new ChoiceWindow(); choice.SetChoiceList(pathlist.Select(p => Path.GetDirectoryName(p))); choice.ShowDialog(); path = choice.ChoiceResult; Directory.CreateDirectory(path); } // move album cover image file var albumPath = FileLocator.GetAlbumImagePath(album); if (albumPath != string.Empty) { File.Move(albumPath, $"{path}\\{Path.GetFileName(albumPath)}"); _albumToMove.LocateImagePath(); } // move folder with song files var albumFolder = FileLocator.FindAlbumPath(album); if (albumFolder != string.Empty) { var destinationFolder = $"{Path.GetDirectoryName(path)}\\{new DirectoryInfo(albumFolder).Name}"; if (Path.GetPathRoot(albumFolder) == Path.GetPathRoot(path)) { Directory.Move(albumFolder, destinationFolder); } // !!!!! .NET, are you kidding me? ((( else { Directory.CreateDirectory(destinationFolder); foreach (string dir in Directory.GetDirectories(albumFolder, "*", SearchOption.AllDirectories)) { Directory.CreateDirectory(Path.Combine(destinationFolder, dir.Substring(albumFolder.Length + 1))); } foreach (string file in Directory.GetFiles(albumFolder, "*", SearchOption.AllDirectories)) { File.Copy(file, Path.Combine(destinationFolder, file.Substring(albumFolder.Length + 1))); } Directory.Delete(albumFolder, true); } } await InsertAlbumToCollectionAsync(_albumToMove); _albumToMove = null; _albumToMovePerformer = null; }