NetWinForm程序园
您的位置: 首页 > 文章列表 > asp.net C# 获取文件详细备注信息
asp.net C# 获取文件详细备注信息
分类: asp.net 开发 发布:2010-9-6 12:41:49 阅读:24223次 评论:0人评论
关键字: 文件备注
C# 获取文件的属性已经有了,在这里,介绍如何获取文件的备注信息,

这一点特别在媒体文件上有用,可以读取一些需要的信息,并可以进行修改操作(我们将在以后介绍)

看这个例子

项目中要应用 Shell32.dll;

using System.IO;
using Shell32;


ShellClass sh
= new ShellClass();
Folder dir
= sh.NameSpace(Path.GetDirectoryName(strPath));
FolderItem item
= dir.ParseName(Path.GetFileName(strPath));
StringBuilder sb
= new StringBuilder();
for (int i = -1; i < 50; i++)
{
// 0 Retrieves the name of the item.
// 1 Retrieves the size of the item.
// 2 Retrieves the type of the item.
// 3 Retrieves the date and time that the item was last modified.
// 4 Retrieves the attributes of the item.
// -1 Retrieves the info tip information for the item.
sb.Append(i.ToString());
sb.Append(
":");
sb.Append(dir.GetDetailsOf(item, i));
sb.Append(
"\r\n");
}
string c = sb.ToString();

strPath 为文件的物理全路径

显示结果为:

-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:



申明:在不同的系统下,顺序有可能不同,请实际测试后适用

    评论交流
我来说两句
用户名: 您目前是匿名发表 登录 | 注册



相关文章
文章分类
推荐阅读