Adding [Metadata] Comments to a File

I am sure that this is possible, just not sure what the term is and how to do it. Basically, if you right-click on any file and go to properties, then you can add comments, etc. To file.

What I want to know is how you can do this with C #. Also, once you have added comments, how can you read these comments from the file for the last time.

I'm sure it has something to do with file metadata, just not sure where to go and look. I will also need to do this on Windows forms, so permissions are not that complicated.

Thanks in advance.

+4
source share
2 answers

An example of using DSO that shows how to set the author and comment fields:

try { DSOFile.OleDocumentPropertiesClass doc = new DSOFile.OleDocumentPropertiesClass(); doc.Open(filename, false, DSOFile.dsoFileOpenOptions.dsoOptionDefault); doc.SummaryProperties.Author = author; doc.SummaryProperties.Comments = comments; doc.Close(true); } catch (Exception ex) { throw new Exception("Could not update the file properties: " + filename, ex); } 
+6
source

As I understand it, most of these properties are unacceptable from user code for security reasons, however, some properties specific to Office Docs can be set using DSOFile. See this MSDN blog for more.

+1
source

All Articles