✅ Editing audio file metadata with TagLib Sharp
Hey there! I'm trying to make a program that streamlines the process of editing file metadata for my music while also giving me a chance to learn something, and I'm running into this problem when I want to set the artist of the track:
The way it's stored in TagLib is using a property
TagLib.File.Tag.Performers
, which is an array of strings. It's initialized to be of length zero, which makes sense, but when I try to set it to a new nonempty array of strings, it just doesn't work, which then leads me to getting an IndexOutOfRangeException
when I inevitably want to set the first value in that array.
I may be making a very very stupid mistake but nonetheless I thought i'd ask.
I don't want to post my code unless someone asks because it's actual programming gore and I know it. Thanks in advance!8 Replies
https://github.com/mono/taglib-sharp/blob/c853d26fcf831b9c7bf1b1bc7734c2a8690ca163/src/TaglibSharp/Id3v1/Tag.cs#L331 looks like you can just re-assign it?
GitHub
taglib-sharp/src/TaglibSharp/Id3v1/Tag.cs at c853d26fcf831b9c7bf1b1...
Library for reading and writing metadata in media files - mono/taglib-sharp
that's what I'm doing
Can you share your code?
alright, it's horrible tho haha
Which line throws the exception?
Ah, I see
well it throws at line 50 but the error is actually at line 48
Mutating the performers array isn't going to work: look at the link I posted. I just does
string.Join
to turn the array back into a ;
- separated string
And when it reads it back into an array from the string, it's going to give you an empty array
So do .Peformers = new[] { Console.ReadLine() }
, or:
If you really want to be verboseah i see
that makes sense
well thanks a lot :D