音乐数据库c#

时间:2013-04-11 18:08:56

标签: c# id3

我正在尝试使用ID3v1TagReader创建一个链接,以便它可以将ID3标记转换为字符串并在我的程序中显示它们。

我用来执行此操作的代码是:

    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 = new ID3v1TagReader.ID3v1Tag();”给出错误:“ID3v1TagReader'类型中不存在类型名称'ID3v1Tag'”

1 个答案:

答案 0 :(得分: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;
    }