Пример #1
0
        private void button_addSong_Click(object sender, EventArgs e)
        {
            // add more then one songs in one try
            openFileDialog.Multiselect = true;
            openFileDialog.Filter = "Mp3 File | *mp3";

            // load all selected songs in list and listbox
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                for (int i = 0; i < openFileDialog.FileNames.Length; i++)
                {
                    Song song = new Song();
                    song.Path = openFileDialog.FileNames[i];
                    song.Name = openFileDialog.SafeFileNames[i];
                    songs.Add(song);
                }
            }

            FillListBox(songs);
        }
Пример #2
0
        private void button_loadPlaylist_Click(object sender, EventArgs e)
        {
            openFileDialog_loadPlaylist.Filter = "Mp3 Player Playlist | *wpl";

            if (openFileDialog_loadPlaylist.ShowDialog() == DialogResult.OK)
            {
                using (FileStream fs = new FileStream(openFileDialog_loadPlaylist.FileName, FileMode.OpenOrCreate))
                {
                    using (StreamReader sr = new StreamReader(fs))
                    {
                        while (!sr.EndOfStream)
                        {
                            Song song = new Song(sr.ReadLine());
                            songs.Add(song);
                        }
                    }
                }
            }

            FillListBox(songs);
        }