C# 在文件外存储元数据:现代Windows上有什么标准方法吗?

C# 在文件外存储元数据:现代Windows上有什么标准方法吗?,c#,windows,metadata,ntfs,extended-properties,C#,Windows,Metadata,Ntfs,Extended Properties,我的C#将文件从远程文档管理系统同步到文件系统 文件管理系统具有元数据(上次审核日期、保密性、作者…),该元数据与每个文件关联,但不存储在每个文件中。 文件可以是任何内容(bmp、xwd、pdf、未知二进制文件) 我想使这些元数据在本地Windows文件系统上可见。 但我不能在每个文件中存储元数据。例如,更改文件的保密性不能修改文件的校验和 存储此元数据的最佳方式是什么 我听说过NTFS,它是否适用于我的场景?所有的答案都是关于修改文件本身,我必须避免 如果没有标准的解决方案,那么我将把元数据存

我的C#将文件从远程文档管理系统同步到文件系统

文件管理系统具有元数据(上次审核日期、保密性、作者…),该元数据与每个文件关联,但不存储在每个文件中。
文件可以是任何内容(bmp、xwd、pdf、未知二进制文件)

我想使这些元数据在本地Windows文件系统上可见。
但我不能在每个文件中存储元数据。例如,更改文件的保密性不能修改文件的校验和

存储此元数据的最佳方式是什么

我听说过NTFS,它是否适用于我的场景?所有的答案都是关于修改文件本身,我必须避免

如果没有标准的解决方案,那么我将把元数据存储在本地SQLite数据库中。但我更愿意使用标准解决方案,以便其他应用程序(资源管理器、图库应用程序等)可以显示/修改它们理解的属性(如“author”)

是NTFS鲜为人知的功能之一。引自该页:

C:\test>echo "ADS" > test.txt:hidden.txt

C:\test>dir
 Volume in drive C has no label.
 Volume Serial Number is B889-75DB

 Directory of C:>test

10/22/2003  11:22 AM    

. 10/22/2003 11:22 AM
.. 10/22/2003 11:22 AM 0 test.txt

C:\test> notepad test.txt:hidden.txt

This will open the file in notepad and allow you to edit it and save it.
它类似于Macintosh资源叉,即它允许将任意数据与文件关联,而不必将其作为文件本身的一部分。默认情况下,Explorer不理解它,但您可以为它编写一个

编辑

可以使用保存某些元数据(如作者和标题)。我不知道它是否修改了文件本身,不过:

private void button1_Click(object sender, EventArgs e)
{
  //This is the PDF file we want to update.
  string filename = @"c:\temp\MyFile.pdf";
  //Create the OleDocumentProperties object.
  DSOFile.OleDocumentProperties dso = new DSOFile.OleDocumentProperties();
  //Open the file for writing if we can. If not we will get an exception.
  dso.Open(filename, false,

    DSOFile.dsoFileOpenOptions.dsoOptionOpenReadOnlyIfNoWriteAccess);
  //Set the summary properties that you want.
  dso.SummaryProperties.Title = "This is the Title";
  dso.SummaryProperties.Subject = "This is the Subject";
  dso.SummaryProperties.Company = "RTDev";
  dso.SummaryProperties.Author = "Ron T.";
  //Save the Summary information.
  dso.Save();
  //Close the file.
  dso.Close(false);
}

谢谢!第二种解决方案只适用于OLE文件,所以我想它会修改文件本身,不幸的是。。。我提出了一个单独的问题来解决这个问题: