【问题标题】:How do I add tags / keywords to a windows file properties details tab using C#如何使用 C# 将标签/关键字添加到 Windows 文件属性详细信息选项卡
【发布时间】:2016-04-16 15:25:44
【问题描述】:

理想情况下,我想使用 shell 类将标签添加到我的办公文档中,但我认为 tags 属性以这种方式是只读项。有人有其他方法吗?

关于这个主题的内容很少。感谢您的帮助。

【问题讨论】:

    标签: file tags document


    【解决方案1】:

    我进一步研究了 shellfile 类。答案就在我眼前。

    string[] keywords = new string[x];
    var shellFile = ShellFile.FromFilePath(file);
    shellFile.Properties.System.Keywords.Value = keywords;
    

    要获取已添加到文件中的关键字,请使用:

    var tags = (string[])shellFile.Properties.System.Keywords.ValueAsObject;
    tags = tags ?? new string[0];
    
    if (tags.Length != 0)
    {
        foreach (string str in tags)
        {
            // code here
        }
    }
    

    完成了!

    【讨论】:

      猜你喜欢
      • 2015-05-05
      • 1970-01-01
      • 2021-12-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多