2013-04-11 62 views
0

我想创建一个ID3v1TagReader的链接,以便它可以将ID3标签转换为字符串并将它们显示在我的程序中。音乐数据库c#

我使用这样做的代码是:

private void button3_Click(object sender, EventArgs e) 
    { 
     //This is refrencing the Tag Reader 
     if (openFileDialog1.ShowDialog() == DialogResult.OK) 
     { 
      ID3v1TagReader tr = new ID3v1TagReader(); 

      ID3v1TagReader.ID3v1Tag ti = new ID3v1TagReader.ID3v1Tag(); 

      //This is telling the tag reader in which field the information must go 
      ti = tr.ReadID3v1Tag(openFileDialog1.FileName); 
      trackTextBox.Text = ti.TrackName; 
      artistTextBox.Text = ti.ArtistsName; 
      albumTextBox.Text = ti.AlbumName; 
      comboBox1.Text = ti.Genres; 
      locationTextBox.Text = openFileDialog1.FileName; 
      yearTextBox.Text = ti.Year; 
     } 
    } 

线 “ID3v1TagReader.ID3v1Tag TI =新ID3v1TagReader.ID3v1Tag();”给出错误:“类型名'ID3v1Tag'在'ID3v1TagReader'类型中不存在'”

+0

这听起来像你缺少一个参考。 – 0xFF 2013-04-11 18:13:53

+0

这些家伙来自哪里:'ID3v1TagReader'和'ID3v1Tag'?你正在开发一个标签阅读器吗?你是否从互联网上的某个地方获得这些课程? – 2013-04-11 18:18:22

+0

你在使用什么库?你肯定缺少一个参考。您是否将ID3v1TagReader的.DLL添加到项目引用? – 2013-04-11 18:18:47

回答

2

如果您使用的库我认为您正在使用(SharpTag,我在网上任意找到),看起来ID3v1Tag型确实不在ID3v1TagReader之内。试试这个:

//This is refrencing the Tag Reader 
    if (openFileDialog1.ShowDialog() == DialogResult.OK) 
    { 
     ID3v1TagReader tr = new ID3v1TagReader(); 

     ID3v1Tag ti = new ID3v1Tag(); 

     //This is telling the tag reader in which field the information must go 
     ti = tr.ReadID3v1Tag(openFileDialog1.FileName); 
     trackTextBox.Text = ti.TrackName; 
     artistTextBox.Text = ti.ArtistsName; 
     albumTextBox.Text = ti.AlbumName; 
     comboBox1.Text = ti.Genres; 
     locationTextBox.Text = openFileDialog1.FileName; 
     yearTextBox.Text = ti.Year; 
    } 
+1

我没有在该类中看到任何'ReadID3v1Tag'方法。 – MusiGenesis 2013-04-11 18:15:12

+0

@MusiGenesis现在你提到它......另外,在该库中,类名是'ID3V1TagReader'而不是'ID3v1TagReader' ...哎呀! – 2013-04-11 18:19:04