c# - 添加自定义文件扩展属性
问题描述
使用此工具为 .svg 扩展添加元数据属性处理程序后,我可以通过 Windows 资源管理器将关键字添加到 .svg 文件。
我现在正在寻找一种通过 C# 应用程序添加关键字的方法。我找到了这个解决方案,但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);
解决方案
推荐阅读
- typescript - 如何在打字稿中编写“反转”类型以反转元组的顺序
- wordpress - 我必须在我网站的某些页面中添加前缀,它会在 wordpress 中显示我现有页面的内容(意味着没有前缀页面)
- c# - 在 PowerShell ISE 中作为 PowerShell 脚本的一部分运行的 c# 代码中使用 ReadLine 从用户那里获取输入
- android - 如何在数据绑定 xml 文件中使用 getLifecycleOwner() 方法
- uwp - 在 uwp 中的 zip 文件名前显示 / 符号
- java - 我们可以在一个 Android 项目中同时使用 OpenTok 和 Jitsi 吗?
- c# - 如何在 google DialogFlow Webhook 中添加 localhost URL?
- python - Flask - RuntimeError:未找到应用程序。在视图函数中工作或推送应用程序上下文
- ios - 为什么 Swift Firebase auth() 响应较晚?
- docker - Docker 容器网络 --format