C#获取文件详细备注信息,MP3的Tag等等

首先必须添加Shell32:程序中需要引用shell32.dll,我的具体步骤如下:在“引用”上右键选“添加引用”,在弹出的对话框中选“COM”选项卡,找到组件“Microsoft Shell Controls AndAutomation 1.0”

using System.IO;
using Shell32;
            OpenFileDialog ofd = new OpenFileDialog();  //new一个方法
            ofd.Filter = "MP3 Files(.mp3)|*.mp3|WMA Files(*.wma)|*.WMA|ALL Files(*.*)|*.*";
            ofd.Multiselect = true;         //允许多选
            ofd.RestoreDirectory = true;    //记住上一次的文件路径
            ofd.ShowDialog();               //显示打开文件的窗口
            filePath = ofd.FileName;        //获取文件的完整的路径

            FileInfo fInfo = new FileInfo(filePath);         

            ShellClass sh = new ShellClass();
            Folder dir = sh.NameSpace(Path.GetDirectoryName(filePath));
            FolderItem item = dir.ParseName(Path.GetFileName(filePath));
            StringBuilder sb = new StringBuilder();
            for (int i = -1; i < 50;i++ )
            {
                sb.Append(i.ToString()) ;
                sb.Append(":");
                sb.Append(dir.GetDetailsOf(item,i));
                sb.Append("\r\n");
            }
            string str = sb.ToString();
输出的结果:

-1:项目类型: MP3 格式声音
大小: 5.42 MB
参与创作的艺术家: 张敬轩
长度: 00:03:51

0:吻得太逼真
1:5.42 MB
2:MP3 格式声音
3:2010/7/30 17:03
4:2011/8/3 0:35
5:2010/7/30 17:03
6:A
7:
8:
9:音频
10:ZJD-PC\ZJD
11:音乐
12:
13:张敬轩
14:Urban Emotions
15:2008
16:华语流行音乐【Chinese Pop Music】
17:
18:
19:未分级
20:张敬轩
21:吻得太逼真
22:
23:
24:
25:
26:14
27:00:03:51
28:?196kbps
29:否
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:



  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值