如何使用C#将标签/关键字添加到Windows文件属性详细信息选项卡 [英] How do I add tags / keywords to a windows file properties details tab using C#
本文介绍了如何使用C#将标签/关键字添加到Windows文件属性详细信息选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
理想情况下,我想使用shell类将标签添加到我的Office文档中,但是我认为tags属性是这种方式的只读项.有人有其他方法吗?
Ideally I would like to use the shell class to add tags to my office documents but I think the tags property is a read only item this way. Does anyone have any other ways?
关于这个主题的内容很少.谢谢您的帮助.
There is very little on the subject. Thank you for your help.
推荐答案
我进一步研究了shellfile类.答案正盯着我.
I looked into the shellfile class a little more. The answer was staring me right in the face.
string[] keywords = new string[x];
var shellFile = ShellFile.FromFilePath(file);
shellFile.Properties.System.Keywords.Value = keywords;
要获取已添加到文件中的关键字,请使用:
to get the keywords already added to the file use:
var tags = (string[])shellFile.Properties.System.Keywords.ValueAsObject;
tags = tags ?? new string[0];
if (tags.Length != 0)
{
foreach (string str in tags)
{
// code here
}
}
完成!
这篇关于如何使用C#将标签/关键字添加到Windows文件属性详细信息选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文