Search code examples
c#taglib-sharp

TglibSharp i cant write to the metadata of an mp3 song


I have been trying to read/write metadata of mp3 files.I searched around a bit and found out i could use Taglibsharp in order to do it.Reading the metadata works perfectly however when i try to write in order to change a tag for example the title nothing happens.Also there is no documentation for taglibsharp so if someone who has previously used it knows what i can do , please help me.Thanks in advance!
Some code:

var tfile = TagLib.File.Create(songPath);
//Reading: works perfectly
string title = tfile.Tag.Title;
//writing: does nothing
tfile.Tag.Title = "A title";

Solution

  • You need to call the .Save() method:

    using (var tfile = TagLib.File.Create(songPath))
    {
        tfile.Tag.Title = "A title";
        tfile.Save();
    }