Mister Verleg
Mister Verleg

Reputation: 4303

How to acces the author name and other docx metadata

I want to use C# to get the metadata of a file, for example a docx. In the screenshot below you see the auteur and other metadata of a file.

Example

How do I write this metadata to the console?

Upvotes: 2

Views: 3879

Answers (1)

Mark G
Mark G

Reputation: 597

A word file in DOCX is packaged as a zip file. The metadata is in an XML file within that zip file. As a very simple way to think about it, this is what you would need to do programmatically through C#:

  1. Unzip the DOCX file into it's folder structure.
  2. Open the core.xml file located in the docProps folder of that structure.
  3. Pull out and store the relevant XML elements that you are looking for, such as title, subject or whatever.
  4. Write those elements with Console.WriteLine().

Image Showing Structure and XML file

Info on Office Open XML format

Upvotes: 3

Related Questions