Reputation: 11
i want to get the author of a file i used this but it's return the pc\user (khawla-pc\khawla) which is not the real author (Ines). can someone help me?
string path="D:/testUsers/Auteurs connus/ff_ines.docx";
string user = System.IO.File.GetAccessControl(path).GetOwner(typeof(System.Security.Principal.NTAccount)).ToString();
Console.WriteLine(user);
Upvotes: 1
Views: 2573
Reputation: 935
To get the author of a word (2007+) document, you can use the OpenXml library and access the PackageProperties of the document.
public string GetAuthor(string documentPath)
{
using (var document = WordprocessingDocument.Open(documentPath, false))
{
return document.PackageProperties.Creator;
}
}
Upvotes: 5