BOUNTY开始了,但我想在C#中做例子
我需要遵循:
在我的申请中,我有文件.需要一直检查和检出的文件.当我从我的应用程序中检查一个Document时,我需要将自定义属性添加到文件中,这样我以后可以在我签入文档时识别它.
我尝试使用以下代码使用DSOFile中的OleDocumentProperties,但没有成功:
// Adding custom properties to file (Parameters: FileName, custom property name, value, debug: true/false
DocumentProperties.WriteDocumentProperty(filename, "dms_dossiernummer", _dossiernummer.ToString(), false);
DocumentProperties.WriteDocumentProperty(filename, "dms_zaaknaam", ReturnZaaknaam(_dossiernummer), false);
DocumentProperties.WriteDocumentProperty(filename, "dms_verantw_medew", ReturnVerantwMedew(_dossiernummer), false);
DocumentProperties.WriteDocumentProperty(filename, "dms_document_path", path, false);
DocumentProperties.WriteDocumentProperty(filename, "dms_bestandsnaam", bestandsNaam, false);
DocumentProperties.WriteDocumentProperty(filename, "dms_bestands_id", bestandId, false);
DocumentProperties.WriteDocumentProperty(filename, "dms_is_checkedout", "true", false);
DocumentProperties.WriteDocumentProperty(filename, "dms_dossier_map_id", dossierMapId, false);
DocumentProperties.WriteDocumentProperty(filename, "dms_bestand_versie_nummer", Queries.Dms.Selects.GetDocumentVersion(
Convert.ToInt32(bestandId)).ToString(), false);
DocumentProperties.WriteDocumentProperty(filename, "dms_bestands_locatie", path, false);
Run Code Online (Sandbox Code Playgroud)
有没有人知道将自定义文件属性添加到文件的另一种方法?
我正在尝试将 .NET Framework 应用程序移植到 .NET Core。该应用程序读取文件的扩展属性,就像在文件资源管理器中右键单击文件时可以看到的那样:
在我的 4.7.2 Framework 应用程序中,代码如下所示:
using Microsoft.WindowsAPICodePack.Shell;
var shellFile = ShellFile.FromFilePath(file.FullName);
var title = shellFile.Properties.System.Title.Value;
var albumTitle = shellFile.Properties.System.Music.AlbumTitle.Value;
Run Code Online (Sandbox Code Playgroud)
我的项目引用了这样的 Shell 代码:
我需要在 .NET Core 应用程序中执行哪些操作才能访问 Microsoft.WindowsAPICodePack.Shell 的代码?或者 .NET Core 是否提供了另一种读取这些文件属性的方法?
在将此问题标记为重复之前
我知道已经有人问过类似的问题: Obtaining file Extended Properties in .Net Core
然而,这个问题是 3 年前提出的,当时 .NET Core 还很年轻。这两个答案没有解释如何读取文件的扩展属性。似乎回答的人不理解扩展文件属性和可以从中获取的文件属性之间的区别FileInfo。也许问题还不够清楚?我还希望 .NET Core 已经得到足够的改进,以便可以再次使用此类遗留功能。