文件之外存储元数据:在现代的Windows任何标准的做法? [英] Store metadata outside of file: Any standard approach on modern Windows?

查看:264
本文介绍了文件之外存储元数据:在现代的Windows任何标准的做法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的C#应用同步文件从远程文件管理系统,文件系统。

My C# app syncs files from a remote document management system to a filesystem.

文档管理系统具有与每个文件相关联,但没有存储中的每个文件的元数据(上次审核,保密,作者...日期)。结果
中的文件可以是任何东西(BMP,XWD,PDF格式的,未知的二进制)

The document management system has metadata (date of last audit, secrecy, author...) which is associated with each file but not stored WITHIN each file.
The files can be anything (bmp, xwd, pdf, unknown binary)

我要让这些元数据在本地Windows文件系统。结果
可见,但我可以T存储元数据中的每个文件。例如,更改文件的保密不得修改文件的校验和。

I want to make these metadata visible on the local Windows filesystem.
But I can't store metadata WITHIN each file. For instance, changing the secrecy of a file must NOT modify the checksum of the file.

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

What is the best way to store this metadata?

我听说过NTFS 扩展的文件属性,是东西适用于我的情况? 这个问题有关设置扩展文件属性拥有所有的答案谈论修改文件本身,这是我必须避免。

I have heard about NTFS extended file attributes, is it something that applies to my scenario? This question about setting extended file properties has all answers talking about modifying the files themselves, which I must avoid.

如果没有标准溶液,那么我将存储在本地SQLite数据库的元数据。不过,我倒很愿意使用一个标准的解决方案,使其他应用程序(探险家,画廊应用等)可显示/修改他们理解的属性(如作者)

If there is no standard solution, then I will store the metadata in a local SQLite database. But I would really prefer to use a standard solution so that other apps (explorer, gallery apps, etc) can display/modify the properties they understand (like "author")

推荐答案

备用数据流是NTFS鲜为人知的功能之一。从页面引用:

Alternate data streams is one of NTFS' less-known features. Quote from the page:

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资源叉,也就是说,它允许相关联与文件的任意数据,没有它该文件本身的一部分。资源管理器默认不理解,但你可以写一个的列处理它。

修改

一些元数据(如作者和书名)可使用的 OLE文档属性。我不知道这是否修改文件本身或没有,但:

Some metadata (such as Author and Title) can be saved using OLE document properties. I don't know if it modifies the file itself or not, though:

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);
}

这篇关于文件之外存储元数据:在现代的Windows任何标准的做法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆