private void OpenDirectory_OnClick(object sender, RoutedEventArgs e) { CommonOpenFileDialog dialog = new CommonOpenFileDialog(); dialog.InitialDirectory = "C:\\Users"; dialog.IsFolderPicker = true; if (dialog.ShowDialog() == CommonFileDialogResult.Ok) { var files = Directory.GetFiles(dialog.FileName, "*.mp3"); Mp3File firstMp3 = new Mp3File(files[0]); Mp3Files.Add(firstMp3); for (int i = 1; i < files.Length; i++) { Mp3Files.Add(new Mp3File(files[i])); } Play(firstMp3); } }
private void OpenButton_OnClick(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog { Multiselect = true, Filter = "mp3 files (*.mp3)|*.mp3" }; openFileDialog.ShowDialog(); if (openFileDialog.FileNames.Length > 0) { Mp3File firstMp3 = new Mp3File(openFileDialog.FileNames[0]); Mp3Files.Add(firstMp3); for (int i = 1; i < openFileDialog.FileNames.Length; i++) { Mp3Files.Add(new Mp3File(openFileDialog.FileNames[i])); } Play(firstMp3); } }