Sasha
Sasha

Reputation: 20854

Is it possible to add custom metadata to file?

I know that each file has metadata like title, subject, keywords and comments:

enter image description here

But what if I need custom metadata like tags for example?

Is it possible to do it with C#?

Upvotes: 12

Views: 28748

Answers (5)

Henk Holterman
Henk Holterman

Reputation: 273611

I know that each file has metadata like title, subject, keywords and comments

That is not true. Most file types do not have a 'standard' form of metadata.

In particular, PDF files don't have properties that Windows Explorer recognizes.

Metadata (file attributes) is not a function of the filesystem.

  • Office files use a structured format that allows for such attributes.
  • Jpeg uses EXIF, a different format.

Upvotes: 8

Simon S.
Simon S.

Reputation: 111

Has anyone thought of using the File ID for this? You can get it via the command

fsutil file queryfileid "C:/my/path/example.txt"

This could be used to store information about this file in a separate storage-file associated with the id.

Upvotes: 0

Jesper Palm
Jesper Palm

Reputation: 7248

If using NTFS you can store whatever you like in an Alternate data stream

Upvotes: 7

RobG
RobG

Reputation: 53

As per Jesper's comment, you can use the DSOFile library to read and write to Custom properties that are stored in ADS.
Works well for me though note the fact that the properties are lost when file is transferred to a different file system, including email. see http://www.keysolutions.com/blogs/kenyee.nsf/d6plinks/KKYE-79KRU6 for a 64bit implementation, link to MS original and comments.

Upvotes: 3

Darin Dimitrov
Darin Dimitrov

Reputation: 1039328

This will depend on whether the file type you are working with supports this. For example this will not be possible with a text file.

Upvotes: 2

Related Questions