示例#1
0
        //Filter by Track Title Done button
        private void metroButton4_Click(object sender, EventArgs e)
        {
            FileStream      FS = new FileStream("mp3.txt", FileMode.Open);
            BinaryFormatter BF = new BinaryFormatter();

            List <MP3Tag_and_nameOf_MP3> list = new List <MP3Tag_and_nameOf_MP3>();

            while (FS.Position < FS.Length)
            {
                MP3Tag_and_nameOf_MP3 Tag = (MP3Tag_and_nameOf_MP3)BF.Deserialize(FS);
                if (Tag.Title == metroComboBox1.SelectedItem.ToString())
                {
                    list.Add(Tag);
                }
            }

            FS.Close();

            FileStream fs = new FileStream("mp3.txt", FileMode.Truncate);

            fs.Close();

            FileStream F = new FileStream("mp3.txt", FileMode.Open);

            for (int i = 0; i < list.Count; i++)
            {
                BF.Serialize(F, list[i]);
            }

            F.Close();

            MessageBox.Show("You have chosen: " + list.Count().ToString() + " song for Title: " + list[0].Title);
            TitlePanel.Hide();
        }