Click here to Skip to main content
15,891,409 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to modify a file's properties programmatically, specifically the details under the 'Summary' tab when you right click on a file: Title, Subject, Author, Category, Comments.
Anybody know how to do this in C++ or C#?
Posted
Updated 10-May-10 23:42pm
v2

You can modify these properties using the Microsoft Developer Support OLE File Property Reader available here[^]. When you have installed this, it allows you to manipulate the underlying OleStorage. Here's a code sample:
MSIL
private void ChangeProp(string file, string author)
{
  DSOFile.OleDocumentPropertiesClass documentProperties = new DSOFile.OleDocumentPropertiesClass();
  DSOFile.SummaryProperties summaryProperties;

  try
  {
    documentProperties.Open(file, false, DSOFile.dsoFileOpenOptions.dsoOptionDefault);

    summaryProperties = documentProperties.SummaryProperties;
    summaryProperties.Author = author;
    documentProperties.Save();
  }
  finally
  {
    summaryProperties = null;
    documentProperties = null;
  }
}
 
Share this answer
 
Comments
Michel Godfroid 11-May-10 5:46am    
Hi Pete, do you know if this works for the new (office 2007) formats?
Pete O'Hanlon 11-May-10 7:23am    
Michel - it does, as long as the end user has the Office 2007 Compatibility Pack installed.
I assume you're talking about office files.
for doc,xls,ppt files this is stored under http://msdn.microsoft.com/en-us/library/aa380369(VS.85).aspx (damn links are broken, this will lead you to definition of structured storage).
for docx,xlsx,pptx files, which are really zip files, I can't remember. You may which to read up on the ODF specification.
Note that you will have an easier task opening all these files with Office Automation, which will allow you to set these properties with little code.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900