【发布时间】:2011-10-17 13:07:05
【问题描述】:
我想在 .NET 代码中设置文件的属性。我尝试过像这样使用 DSOFile (v2.1):
var properties = new OleDocumentProperties();
try
{
properties.Open(filePath);
properties.SummaryProperties.Title = "foo";
properties.Save();
}
finally
{
properties.Close();
}
它适用于 Office 文档。 (我已经使用 Word 和 Excel 进行了测试。)但是,我也想对其他类型的文档进行测试。当我尝试使用 PDF 或 TXT 文件时,出现以下异常:
System.Runtime.InteropServices.COMException (0x800300FC):名称 无效。 (来自 HRESULT 的异常:0x800300FC (STG_E_INVALIDNAME)) 在 DSOFile._OleDocumentProperties.Save()
除了设置SummaryProperties,我还设置了CustomProperties。这也适用于 Office 文件,但不适用于其他文件。我的文件系统是 NTFS。
如何使用 DSOFile 或任何其他技术设置属性(标准和自定义)?
【问题讨论】:
标签: .net windows file metadata