使用Shell32.Shell获取Mp3的持续时间

时间:2014-02-08 12:38:05

标签: c# winforms

我有以下代码来获取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;
}

0 个答案:

没有答案