首页 > 解决方案 > GetDetailsOf() 中的 Shell32 属性是否跨文件夹更改?

问题描述

我在 C# 应用程序中使用 Shell32 从多个目录中的文件(特别是从跨多个文件夹的图片)获取扩展属性。我在 SO 上找到的一种技术(效果很好)是:

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(
              $"{i}\t{arrHeaders[i]}: {objFolder.GetDetailsOf(item, i)}");
        }
    }
}

我做了一些调查,看起来属性名称(显然不是它们的值)在我的 C: 驱动器上的所有文件夹中都是相同的。有谁知道我是否可以指望这个?(我使用的是 Windows 10。)我似乎找不到很多好的 Microsoft 文档。

[编辑] 我编写了一个快速程序来扫描所有我可以扫描的目录,然后计算其中有多少具有哪些属性。这是结果;我不确定它告诉我什么,除了大多数(但不是全部)属性在大多数(但不是全部)文件夹中都很常见:

Attribute                 Directories
------------------------- -----------
#                         203485
Album                     203485
Attributes                203485
Authors                   203485
Availability              203485
Bit rate                  203485
Camera maker              203485
Camera model              203485
Categories                203485
Category                  1
Collection                1
Comments                  203485
Company                   203485
Conductors                203485
Contributing artists      203485
Copyright                 203485
Creation Date             1
Date accessed             203485
Date created              203486
Date Deleted              1
Date modified             203488
Date taken                203485
Designed for              1
Designer/foundry          1
Dimensions                203485
Family                    1
File description          203485
Folder path               2
Font embeddability        1
Font file names           1
Font style                1
Font type                 1
Font version              1
Genre                     203485
Item type                 203487
Kind                      203485
Last Accessed             1
Last Synchronization      1
Length                    203485
Location                  1
Masters keywords          406974
Name                      203489
Offline status            203485
Original Location         1
Owner                     203485
Perceived type            203485
Program File              1
Protected                 203485
Rating                    203485
Show/hide                 1
Size                      203489
Status                    2
Subject                   203485
Tags                      203487
Time Period               1
Title                     203485
Total Size                1
Version                   1
Year                      203485

标签: c#dll

解决方案


推荐阅读