/// <summary> /// Fills the collection with songs. /// </summary> /// <param name="files">array of song paths.</param> public static void FillCollectionWithSongs(List <string> files) { MyMessages.NameOfMethod = MethodBase.GetCurrentMethod().Name; foreach (var songPath in files) { SongsCollection.AddItem(songPath); } }
/// <summary> /// Fills the collection with songs. Add all of the songs found in the /// users music collection to SongsCollection class. /// </summary> /// <returns> /// <c>true</c>, if collection with songs was filled, <c>false</c> otherwise. /// </returns> /// <param name="songPaths">Song paths.</param> private bool FillCollectionWithSongs(string[] songPaths) { var retVal = false; var songPathNotFound = string.Empty; try { MyMessages.NameOfMethod = MethodBase.GetCurrentMethod().Name; foreach (var songPath in songPaths) { songPathNotFound = songPath; var compMp3 = -1; var fifo = new FileInfo(songPath); compMp3 = string.Compare(fifo.Extension, ".mp3", StringComparison.OrdinalIgnoreCase); // If .mp3 music file add it to the collection. if (compMp3 == 0) { if (!File.Exists(songPath)) { MyMessages.ErrorMessage = "Invalid file path. This will not be added to the collection."; MyMessages.ErrorMessage = string.Concat(MyMessages.ErrorMessage, Environment.NewLine); MyMessages.ErrorMessage = string.Concat(MyMessages.ErrorMessage, songPath); MyMessages.ShowErrorMessage(MyMessages.ErrorMessage, MyMessages.NameOfClass); } if (loadAllSongs) { SongsCollection.AddItem(songPath); } } else if (loadGenreWorkingDirectory) { SongsCollection.AddItem(songPath); SongsCollection.AddItem(songPath); } } // All OK retVal = true; return(retVal); } catch (UnauthorizedAccessException ex) { MyMessages.ErrorMessage = "You do not have authorization to access this directory."; MyMessages.ErrorMessage = string.Concat(MyMessages.ErrorMessage, Environment.NewLine); MyMessages.ErrorMessage = string.Concat(MyMessages.ErrorMessage, songPathNotFound); MyMessages.BuildErrorString(MyMessages.NameOfClass, MyMessages.NameOfMethod, MyMessages.ErrorMessage, ex.Message); return(retVal); } }