我正在使用以下API https://gist.github.com/1285901
到目前为止我有这个代码但是当它试图读取标签时它们都返回空白(通过标签我的意思是艺术家信息等)
using System;
using System.IO;
using Microsoft.WindowsAPICodePack.Shell;
using Microsoft.WindowsAPICodePack;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Files();
Console.Read();
}
public static void Files()
{
FileInfo fi = new FileInfo(@"C:\Users\santised\Desktop\music\");
DirectoryInfo di = fi.Directory;
FileSystemInfo[] fsi = di.GetFiles();
foreach (FileSystemInfo info in fsi)
{
Console.Write(info.Name.Replace(".mp3", "") + " Tags: " + Tags(@"C:\Users\santised\Desktop\music\" + info.Name) + "\r\n");
}
}
public static String Tags(String fileName)
{
if (File.Exists(fileName))
{
var file = new FileInfo(fileName);
String returnval = String.Join("; ", file.GetTags()); // .GetTags() is from the api on gist hub
return returnval;
}
return "None;";
}
}
}
答案 0 :(得分:0)
您正在使用的库检索归因于Windows中文件的标记:它不会检索MP3元数据(ID3)标记。您需要找到一个能够读取ID3标签的库,例如TagLib Sharp
答案 1 :(得分:0)
你可以使用taglib-sharp
从here下载
然后尝试
var file = TagLib.File.Create(address);
var t1 = file.Tag.Copyright;
var t2 = file.Tag.Album;
var t3 = file.Tag.AlbumArtists;
var t4 = file.Tag.Title;
var t5 = file.Tag.Comment ;
var t6 = file.Tag.Composers ;
var t7 = file.Tag.Conductor ;
var t8 = file.Tag.Grouping;
var t9 = file.Tag.Artists ;