添加自定义文件扩展属性

时间:2020-01-27 09:51:02

标签: c# .net windows-api-code-pack file-properties propertyhandler

在使用this tool添加.svg扩展名的元数据属性处理程序之后,我可以通过Windows资源管理器向.svg文件中添加关键字。

FileMeta Association Manager

我现在正在寻找一种通过C#应用程序添加关键字的方法。我发现this solution,但是System.AccessViolationException被抛出以下代码:

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;

是什么原因?


编辑:

此方法正常工作,但是如果标签长度太长,则会抛出COMException

using DSOFile;

var file = new OleDocumentProperties();
file.Open(path);
file.SummaryProperties.Keywords = string.Join(";", tags);
file.Close(true);

0 个答案:

没有答案