File 如何使用C向windows文件属性详细信息选项卡添加标记/关键字#

File 如何使用C向windows文件属性详细信息选项卡添加标记/关键字#,file,tags,document,File,Tags,Document,理想情况下,我希望使用shell类将标记添加到office文档中,但我认为tags属性是一个只读项。有人有其他方法吗 关于这个问题几乎没有什么。谢谢您的帮助。我进一步研究了shellfile类。答案就在我面前 string[] keywords = new string[x]; var shellFile = ShellFile.FromFilePath(file); shellFile.Properties.System.Keywords.Value = keywords; 要获取已添加到文

理想情况下,我希望使用shell类将标记添加到office文档中,但我认为tags属性是一个只读项。有人有其他方法吗


关于这个问题几乎没有什么。谢谢您的帮助。

我进一步研究了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
    }
}
完成了