0

我正在尝试使用 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();” 给出错误:“类型名称 'ID3v1Tag' 不存在于类型 'ID3v1TagReader' 中”

4

1 回答 1

2

如果您使用的是我认为您正在使用的库(SharpTag,我在互联网上任意找到的),那么该类型似乎ID3v1Tag确实不在 inside 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;
    }
于 2013-04-11T18:14:11.407 回答