-1

At the first when I want to create a file with Taglib I get following error.

Error:

CS1503 Argument 1: cannot convert from 'string' to 'TagLib.File.IFileAbstraction'

string fileToOpen=@"D:\music.mp3";
TagLib.File musicinfo = TagLib.File.Create(fileToOpen);
textBox5.Text = musicinfo.Tag.Title;
textBox2.Text = musicinfo.Tag.FirstAlbumArtist;
textBox3.Text = musicinfo.Tag.Album;

The path of the file is a string, why does this error appear ?

1 Answers1

0

Make sure ,you use correct TagLib.

Nuget : https://www.nuget.org/packages/taglib/2.1.0

Github : https://github.com/mono/taglib-sharp

File file = TagLib.File.Create("string path");

class Program
{
    static void Main(string[] args)
    {
        File file = TagLib.File.Create(@"C:\Users\MSU-01\Desktop\asd.mp3");
        string title = file.Tag.Title;
        Console.WriteLine(title);
        Console.ReadLine();
    }
}
OMANSAK
  • 1,066
  • 1
  • 12
  • 30
  • I'm doing exactly this, but am seeing compile error "cannot convert from 'string' to 'TagLib.File.IFileAbstraction'". Not sure what I'm doing wrong, I got the latest from nuget and passing in a string for the filepath. Any ideas? Thanks. – PHenry Nov 11 '20 at 03:53
  • @PHenry Did u try https://github.com/mono/taglib-sharp#readwrite-metadata-from-a-video ? – OMANSAK Nov 14 '20 at 16:57
  • Thank you OMANSAK for the reply. No, I haven't tried that link..yet. But I was able to get it working, however I needed to do a bit more fiddling with the code to get the stream working, that's the part I found frustrating. The Create now does not seem to use a string (filename) as input and only a stream (and I don't know enough about streams to 'just wing it' unfortunately).Thank you for your time and reply. – PHenry Nov 14 '20 at 19:25