自定义文件属性 [英] Custom File Properties

查看:183
本文介绍了自定义文件属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

BOUNTY起步,但我想要的例子在C#

BOUNTY STARTED, BUT I WANT EXAMPLES IN C#

我需要以下内容:

在我的应用我有证件。这就需要文档中和所有的时间进行检查。当我检查出文档我的申请,我需要自定义属性添加到该文件,所以我可以在我要去签文件后识别它。

In my application I have documents. Documents which need to be checked in and out all the time. When I check a Document out of my application I need to add Custom Properties to the file so I can identify it later when I'm going to checkin the document.

我已经尝试使用下面的代码使用从DSOFile的OleDocumentProperties,但没有成功:

I've tried to use the OleDocumentProperties from DSOFile using the following code, but no success:

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



有谁知道另一种方式自定义文件属性添加到文件?

Does anyone know another way to add Custom File Properties to a file?

推荐答案

基本上,一个文件只是一个字节和一些流该文件的文件系统关联到它的元数据。在早期的文件系统元数据基本上只是文件名和一些日期戳。像NTFS较新的文件系统有添加额外的元数据的选项。

What is a File?

Basically, a file is just a stream of bytes and some metadata that file file system associates with it. In early file systems the metadata was basically just the file name and some date stamps. Newer file systems like NTFS have the option of adding extra metadata.

在Windows资源管理器,你可以看到相当多的文档属性的许多文件类型。漂亮的,统一的界面显示,有一些统一的属性存储。这不是真的如此。在资源管理器外壳有属性表处理程序的可扩展接口的提取各种文件类型此信息。没有为 JFIF处理程序(JPEG)文件,并有对OLE文件句柄(旧Office格式),以及。新的Office格式太

In Windows Explorer you can see quite a lot of document properties for many file types. The nice, unified interface suggests that there is some unified property store. That's not really the case. The Explorer Shell has an extensible interface for Property Sheet Handlers that extract this information from various file types. There is a handler for JFIF (JPEG) files, and there are handlers for OLE files (old Office formats), and the new Office formats too.

结论是:


  • 如果你能保证,你只需要处理某些文件格式,调查中 EM>文件。例如,

  • If you can guarantee that you only need to handle certain file formats, investigate adding the metadata within the files. For example,


  • OLE属性如果您所有的文件都是旧式的Office文档(.doc)

  • OLE properties if all your files are old-style Office documents (.doc)

使用开放式XML API 如果您所有的文件都是新的样式Office文档文件(.docx)

Using the Open XML API if all your documents are new-style Office documents (.docx)

如果你能保证所有的安装将是一个特定的文件系统上,研究了文件系统的功能。其他答复考虑,你可以如何使用NTFS做到这一点。

If you can guarantee that all installations will be on a specific file system, investigate features of the file system. Other responses have considered how you could do this with NTFS.

否则,您必须设计自己的数据存储。配套文件是一个明显的可能性;可以存储在数据库中的元数据;或者你可以创建每个目录一个文件来保存所有元数据在该目录中的文件。考虑一下你是否会面临对同一文件的多个请求并发问题。使用数据库的可能的使处理更简单。

Otherwise you must devise your own data store. Companion files are an obvious possibility; you could store the metadata in a database; or you could create one file per directory to hold all the metadata for files in that directory. Consider whether you might face concurrency problems with multiple requests for the same file. Using a database might make dealing with that more straightforward.

这篇关于自定义文件属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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