C# 获取mp3文件的歌曲时间长度
通过读取目录文件信息,进行解析,简单快捷!
添加命名空间:
using Shell32;
using System.Text.RegularExpressions;
添加引用:COM组件的Microsoft Shell Controls And Automation
string dirName = Path.GetDirectoryName(SongPath);
SongName = Path.GetFileName(SongPath);//获得歌曲名称
FileInfo fInfo = new FileInfo(SongPath);
ShellClass sh = new ShellClass();
Folder dir = sh.NameSpace(dirName);
FolderItem item = dir.ParseName(SongName);
SongTime = Regex.Match(dir.GetDetailsOf(item, -1), "\\d:\\d{2}:\\d{2}").Value;//获取歌曲时间
posted on 2012-01-31 14:02 Mr. running 阅读(782) 评论(0) 编辑 收藏 举报