我有以下代码来获取mp3文件持续时间,但它返回空字符串。 该文件位于驱动器c:
中private string GetDuration(string FileFullPath)
{
string duration = "";
string fName = FileFullPath.Substring(FileFullPath.LastIndexOf("\\") + 1);
string filePath = FileFullPath.Substring(0, FileFullPath.LastIndexOf("\\"));
Shell32.Shell shell = new Shell32.ShellClass();
Shell32.Folder folder = shell.NameSpace(filePath);
Shell32.FolderItem folderItem = folder.ParseName(fName);
if (folderItem != null)
{
duration = folder.GetDetailsOf(folderItem, 21); //Only Empty for 21
}
folderItem = null;
folder = null;
shell = null;
return duration;
}