读/写'扩展'文件属性(C#) [英] Read/Write 'Extended' file properties (C#)

查看:166
本文介绍了读/写'扩展'文件属性(C#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我试图找出如何读/写C#中的扩展文件属性
例如评论,比特率,访问日期,类别等,你可以在Windows资源管理器看到的。
任何想法如何做到这一点?
编辑:我主要是进行读/写视频文件(AVI / DIVX /...)

Hi I'm trying to find out how to read/write to the extended file properties in C# e.g. Comment, Bit Rate, Date Accessed, Category etc that you can see in Windows explorer. Any ideas how to do this? I'll mainly be reading/writing to video files (AVI/DIVX/...)

推荐答案

对于那些不热衷于VB,在这里它是在C#中:

For those of not crazy about VB, here it is in c#:

public static void Main(string[] args)
{
    List<string> arrHeaders = new List<string>();

    Shell32.Shell shell = new Shell32.Shell();
    Shell32.Folder objFolder;

    objFolder = shell.NameSpace(@"C:\temp\testprop");

    for( int i = 0; i < short.MaxValue; i++ )
    {
        string header = objFolder.GetDetailsOf(null, i);
        if (String.IsNullOrEmpty(header))
            break;
        arrHeaders.Add(header);
    }

    foreach(Shell32.FolderItem2 item in objFolder.Items())
    {
        for (int i = 0; i < arrHeaders.Count; i++)
        {
            Console.WriteLine("{0}\t{1}: {2}", i, arrHeaders[i], objFolder.GetDetailsOf(item, i));
        }
    }
}

这篇关于读/写'扩展'文件属性(C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆