.NET Aspose.Words - Getting document properties added by Sharepoint

I have a SharePoint library where I added two columns for documents: ProjectId and ClientName.


I populate these values for a document through the SharePoint interface, then download the document. When I open the document in the desktop version of Word, I can see the populated fields in the document properties.

I am interested in how I can retrieve the values of these fields. I have tried looking for them in the CustomDocumentProperties and BuiltInDocumentProperties collections but could not find them there.

I have attached an example of a blank document with the ProjectId and ClientName properties filled in.

Document.docx (18.5 KB)

@m.lakhno The properties defined by SharePoint are not stored neither in CustomDocumentProperties nor in BuiltInDocumentProperties. They are stored in custom XML. You can access custom XML using Document.CustomXmlParts property. For example see the following code:

Document doc = new Document(@"C:\Temp\in.docx");

foreach (CustomXmlPart part in doc.CustomXmlParts)
{
    XmlDocument xmlPart = new XmlDocument();
    using (MemoryStream xmlPartStream = new MemoryStream(part.Data))
    {
        xmlPart.Load(xmlPartStream);
        if (xmlPart.DocumentElement.LocalName == "properties")
        {
            Console.WriteLine(xmlPart.DocumentElement.OuterXml);
        }
    }
}