C#获取文件详细备注信息

项目中引用 Shell32.dll;

  1. using System.IO;
  2. using Shell32;

  3.          
  4.             ShellClass sh = new ShellClass();
  5.             Folder dir = sh.NameSpace(Path.GetDirectoryName(strPath));
  6.             FolderItem item = dir.ParseName(Path.GetFileName(strPath));
  7.             StringBuilder sb = new StringBuilder();
  8.             for (int i = -1; i < 50; i++)
  9.             {
  10.                 // 0 Retrieves the name of the item. 
  11.                 // 1 Retrieves the size of the item. 
  12.                 // 2 Retrieves the type of the item. 
  13.                 // 3 Retrieves the date and time that the item was last modified. 
  14.                 // 4 Retrieves the attributes of the item. 
  15.                 // -1 Retrieves the info tip information for the item. 
  16.                 sb.Append(i.ToString());
  17.                 sb.Append(":");
  18.                 sb.Append(dir.GetDetailsOf(item, i));
  19.                 sb.Append("/r/n");
  20.             }
  21.             string c = sb.ToString();

结果:

-1:艺术家: 谭晶
唱片标题: 北京2008奥运会歌曲专辑
发行年: 2008
曲目号码: 20
持续时间: 0:04:21
类型: MP3 格式声音
比特率: 128kbps
受保护: 否
大小: 3.98 MB                                  -----全部


0:一起飞(谭晶 阎维文).mp3          ------文件名
1:4,083 KB                                       ------文件大小
2:MP3 格式声音                              -----文件类型
3:2008-9-3 12:58                               -----修改时间
4:2008-8-26 11:44                            ------创建时间
5:2008-9-3 12:58                             ------访问时间
6:A                                                  

7:在线
8:Administrators
9:谭晶                                             -------作者
10:一起飞                                       -------标题
11:
12:Pop                                              -----------流派
13:
14:思恒网—新闻工作者的摇篮!ww -------备注
15:
16:谭晶                                                -----艺术家
17:北京2008奥运会歌曲专辑             -----唱片标题
18:2008                                                 -----发行年
19:20                                                    ------曲目号码
20:Pop                                                 -----流派
21:0:04:21                                              ------持续时间

22:128kbps                                         ------比特率
23:否                                                       -----受保护
24:
25:
26:
27:
28:
29:
30:
31:
32:0 位                           
33:44 kHz                                      ------音频采样级别
34:2 (立体声)                               -------频道
35:

 

猜你喜欢

转载自blog.csdn.net/bruce135lee/article/details/80856521
今日推荐