After adding metadata property handler for .svg extension with this tool, I am able to add keywords to .svg files via Windows Explorer.
I am now searching a way to add keywords via a C# application. I found this solution but System.AccessViolationException
is thrown with the code:
using Microsoft.WindowsAPICodePack.Shell;
var tags = new[] {"foo", "bar"};
var file = ShellFile.FromFilePath(path);
// following statement throws System.AccessViolationException
file.Properties.System.Keywords.Value = tags;
What can be the cause?
Edit:
This method works correctly but COMException
is thrown if tag length is too high.
using DSOFile;
var file = new OleDocumentProperties();
file.Open(path);
file.SummaryProperties.Keywords = string.Join(";", tags);
file.Close(true);