Wednesday, 2 October 2013

TaglibSharp doesn't do anything

TaglibSharp doesn't do anything

I have a method to replace something in name of the music's artist id3
tag. I'm using taglibSharp and this is my code:
public static void TagArtistRename(this FileInfo file, string from, string
to, bool UseRegex = true)
{
TagLib.File f = TagLib.File.Create(file.FullName);
for (int i = 0; i < f.Tag.Performers.Count(); i++)
{
if (UseRegex)
{
f.Tag.Performers[i] = Regex.Replace(f.Tag.Performers[i], from,
to);
}
else
{
f.Tag.Performers[i] = f.Tag.Performers[i].Replace(from, to);
}
}
f.Save();
}
and here I call my code:
static void Main(string[] args)
{
string file = Console.ReadLine();
file = file.Replace("\"", "");
new FileInfo(file).TagArtistRename(" (www.Downloadha.com)", "", false);
TagLib.File f = TagLib.File.Create(file);
foreach (var item in f.Tag.Performers)
{
Console.WriteLine(item);
}
Console.ReadLine();
}
the code runs without any exceptions but in console, it'll write the old
artists names and also the file's metadata doesn't change.

No comments:

Post a Comment