Пример #1
0
        private void StartButton_Click(object sender, RoutedEventArgs e)
        {
            string startFolder = @"C:\Users\ppras_000\Desktop\Creating Lasting Change";

            DirectoryInfo di = new DirectoryInfo(startFolder);

            foreach (var dir in di.GetDirectories())
            {
                foreach (var file in dir.GetFiles("*.mp3"))
                {
                    using (FileStream fs = new FileStream(file.FullName, FileMode.Open))
                    {
                        using (var mp3 = new Mp3Stream(fs, Mp3Permissions.ReadWrite))
                        {
                            Id3Tag tag = mp3.GetTag(Id3TagFamily.Version2x);
                            tag.Title.Value = file.Name.Substring(0, 2);
                            tag.Album.Value = dir.Name.Substring(0, 6);
                            mp3.WriteTag(tag);
                        }
                    }
                }
            }



            MessageBox.Show("Done");
        }
Пример #2
0
        public void Write(Mp3MetaData mp3MetaData, string inputFilePath)
        {
            using (var fileStream = new FileStream(inputFilePath, FileMode.Open))
            {
                using (var mp3 = new Mp3Stream(fileStream, Mp3Permissions.ReadWrite))
                {
                    mp3.DeleteAllTags(); // make sure the file got no tags

                    var id3Tag = new Id3Tag();
                    id3Tag.Title.Value = mp3MetaData.Title;
                    foreach (var artist in mp3MetaData.Artists)
                    {
                        id3Tag.Artists.Value.Add(artist);
                    }
                    id3Tag.Album.Value = mp3MetaData.Album;
                    id3Tag.Year.Value  = mp3MetaData.Year;
                    id3Tag.Pictures.Add(new PictureFrame()
                    {
                        PictureType = PictureType.FrontCover, PictureData = mp3MetaData.Cover
                    });

                    mp3.WriteTag(id3Tag, 2, 3);
                }
            }
        }