views:

177

answers:

2

Hi

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

What i want to know is how would you do this problematically from c#. Also once you have added comments , how can you at a latter time read these comments from the file.

I am sure it has something to do with the metadata of a file just not sure where to go and look.Also i would need to do this in Windows forms so permissions is not that much of a problem.

Thanks in advance.

+1  A: 

As I understand it, most of these properties are unsettable from user code for security reasons - however, some of the properties specific to Office Documents can be set using DSOFile. See this MSDN Blog for more

TML
+6  A: 

An example using DSO which shows how to set the author & 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);
}
Mike Kruger
Mike Kruger
Yeah thanks , i was just going to mention that the articles links dont work anymore :).
RC1140