This project has moved and is read-only. For the latest updates, please go here.

Editing CoreProperties

Feb 7, 2012 at 7:18 PM

Is there a way to edit DocX.CoreProperties?

The following code has no effect . . .

using (DocX d = DocX.Load(@"C:\Temp\Sample.docx"))
    d.CoreProperties["cp:lastModifiedBy"] = "Bobby";



The following code causes an error on the CoreProperties.Add line because it says the given key already exists in the collection . . .

using (DocX d = DocX.Load(@"C:\Temp\Sample.docx"))
    d.CoreProperties.Remove("cp:lastModifiedBy");    // no error
    d.CoreProperties.Add("cp:lastModifiedBy", "Bobby"); // error


Jan 26, 2013 at 9:22 PM
Edited Jan 26, 2013 at 9:23 PM

Bit late I realise, but it may help someone else.

Looks like d.CoreProperties is just a defensive copy.


document.AddCoreProperty("cp:lastModifiedBy", "Bobby")
Apr 25, 2015 at 1:01 PM
I've tried document.AddCoreProperty with no success
everything else so far is great
Oct 13, 2015 at 7:59 PM
Edited Oct 13, 2015 at 7:59 PM
Using AddCoreProperty results in an error: "Core properties part doesn't exist."

I noticed document.CoreProperties results in count = 0 which makes me think core.xml is not being populated.

It seems to be expecting a /docProps/core.xml package part. Is there anyways to verify this part was created?