I will get you started and then let you finish up, this is really not a difficult task. If you read ID3 made easy[^], they explain the byte layout for the ID3 tag within a file. If you have further questions please feel free to post here. The following should get the ID3 tag out of your file:
class ID3Tag
{
public string title;
public string artist;
public string album;
public string year;
public string comment;
public string tracknumber;
public string genre;
}
private ID3Tag GetTag(string file)
{
string strTag = string.Empty;
ID3Tag tag = new ID3Tag();
ASCIIEncoding encoding = new ASCIIEncoding();
FileStream fs = new FileStream(file, FileMode.Open);
if(fs != null)
{
byte[] block = new byte[128];
fs.Seek(-128, SeekOrigin.End);
fs.Read(block, 0, 128);
fs.Close();
strTag = encoding.GetString(block);
if(strTag.Substring(0,3) == "TAG")
{
tag.title = strTag.Substring(3, 30);
tag.artist = strTag.Substring(33, 30);
tag.album = strTag.Substring(63, 30);
tag.year = strTag.Substring(93, 4);
tag.comment = strTag.Substring(97, 28);
if(strTag\[125\] == 0)
{
tag.tracknumber = strTag\[126\];
}
else
{
tag.tracknumber = 0;
}
tag.genre = strTag\[127\];
}
}
return tag;
}
HTH - Nick Parker
My Blog | My Articles