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.
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.
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
}
}
and done!