/// <summary> /// Retrieve all artist directories in users music collection. /// </summary> /// <param name="genreDirPath">Path to the genre directory.</param> public void GetAllArtistDirectories(string genreDirPath) { MyMessages.NameOfMethod = MethodBase.GetCurrentMethod().Name; if (string.IsNullOrEmpty(genreDirPath) || !Directory.Exists(genreDirPath)) { MyMessages.ErrorMessage = "The genre directory path is invalid."; MyMessages.ShowErrorMessage(MyMessages.ErrorMessage, MyMessages.NameOfMethod); } // TODO: finish getting all artist directories. Debug.Assert(genreDirPath != null, "genreDirPath != null"); var artistPaths = new List <string>( Directory.EnumerateDirectories(genreDirPath, "*", SearchOption.TopDirectoryOnly)); foreach (var artistPath in artistPaths) { var itemPath = PathOperations.ReverseString(artistPath); var artistName = PathOperations.GetNameBeforeFirstSeparator(itemPath); artistName = PathOperations.ReverseString(artistName); ArtistNamesCollection.AddItem(artistName); ArtistDirectoryDictionaryCollection.AddItem(artistName, artistPath); } }
/// <summary> /// Get All artist directories for this genre music return them in a list collection. /// </summary> /// <param name="genreDirPath"></param> /// <returns></returns> public List <string> GetArtistDirectories(string genreDirPath) { var artists = new List <string>(); MyMessages.NameOfMethod = MethodBase.GetCurrentMethod().Name; if (string.IsNullOrEmpty(genreDirPath) || !Directory.Exists(genreDirPath)) { MyMessages.ErrorMessage = "The artist directory path is invalid."; MyMessages.ShowErrorMessage(MyMessages.ErrorMessage, MyMessages.NameOfMethod); } Debug.Assert(genreDirPath != null, "genreDirPath != null"); var artistPaths = new List <string>( Directory.EnumerateDirectories(genreDirPath, "*", SearchOption.TopDirectoryOnly)); foreach (var artistPath in artistPaths) { var itemPath = PathOperations.ReverseString(artistPath); var artistName = PathOperations.GetNameBeforeFirstSeparator(itemPath); artistName = PathOperations.ReverseString(artistName); artists.Add(artistPath); } return(artists); }
/// <summary> /// Get all Genre directories from music directory. /// Add all Genre directories found to genreDirectoriesCollection. /// </summary> public void GetAllGenreDirectories(string musicDirPath) { MyMessages.NameOfMethod = MethodBase.GetCurrentMethod().Name; if (string.IsNullOrEmpty(musicDirPath)) { MyMessages.ErrorMessage = "Not a valid path to music directory."; MyMessages.ShowErrorMessage(MyMessages.ErrorMessage, MyMessages.NameOfMethod); } Debug.Assert(musicDirPath != null, "musicDirPath != null"); var geneDirectories = new List <string>( Directory.EnumerateDirectories(musicDirPath, "*", SearchOption.TopDirectoryOnly)); GenreDirectoryNamesUsersCollection.ClearCollection(); if (geneDirectories.Count <= 0) { return; } foreach (var genrePath in geneDirectories) { GenreDirectoriesCollection.AddItem(genrePath); var itemPath = PathOperations.ReverseString(genrePath); var genreName = PathOperations.GetNameBeforeFirstSeparator(itemPath); genreName = PathOperations.ReverseString(genreName); // check and make sure this is a valid genre directory name. There could be other directory // types. if (ValidateOperations.ValidateFormatGenreDirectoryName(genreName)) { GenreDirectoryNamesUsersCollection.AddItem(genreName); GenreFileReadWrite.WriteGenreUsersList(); } } }