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

1.从系统Window/System32文件夹中Copy出 Shell32.dll Com组件

将Shell32.dll文件引用到项目中,并设置“嵌入互操作类型”为false

http://blog.csdn.net/u011127019/article/details/52166033

2.代码实例:

ShellClass sh = new ShellClass();
Folder dir = sh.NameSpace(Path.GetDirectoryName(filename));
FolderItem item = dir.ParseName(Path.GetFileName(filename));
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();
索引说明(视频文件常用属性):

0--文件名称

1---文件大小
2---文件类型
3---修改时间
4---创建时间
8---可用性
27---时长

28--比特率

303--数据速率

304--帧高度

305--帧速率

306--帧宽度

307--视频方向

308--总比特率

3.代码实例(有不可取的地方):

//初始化Shell接口
ShellClass sh = new ShellClass();
//获取文件所在父目录对象
Folder dir = sh.NameSpace(Path.GetDirectoryName(filename));
//获取文件对象的FolderItem对象
FolderItem item = dir.ParseName(Path.GetFileName(filename));
//字典存放属性名和属性值
Dictionary<string, string> dic = new Dictionary<string, string>();
//循环获取详细信息
int i = 0;
while (true)
{
    //获取属性名称
    string key = dir.GetDetailsOf(null,i);
    if (string.IsNullOrEmpty(key))
    {
        //当无属性可取时,退出循环
        break;
    }
    //获取属性值
    string value = dir.GetDetailsOf(item,i);
    dic.Add(key,value);
    i++;
}
listBox.ItemsSource = dic;

更多:

ffmpeg ffplay ffprobe资料整理

C#使FFmpeg 将视频格式转换成MP4示例

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值