2013-04-11 72 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