How do determine if a document is password protected

How can I tell whether a Word document is password-protected or not? I understand that the doc.BuiltInDocumentProperties.Security propery isn’t necessarily accurate because Microsoft doesn’t alway set this property. Are there any viable alternatives?
Thanks.
Jim McFadden / Unum

Hello

Thanks for your request.

  1. If you specify “Password to open” - BuiltInDocumentProperties.Security = PasswordProtected
    You should check LoadFormat using DetectFileFormat method:
    https://docs.aspose.com/words/net/detect-file-format-and-check-format-compatibility/
    If returned format is OoxmlEncrypted or DocEncrypted then the document is PasswordProtected.

  2. If you specify “Password to modify” - BuiltInDocumentProperties.Security = ReadOnlyEnforced
    In this case you can use WriteProtection property to retrieve this protection status:
    https://reference.aspose.com/words/net/aspose.words/document/writeprotection/

  3. If you check “Read-only recommended” checkbox - BuiltInDocumentProperties.Security = ReadOnlyRecommended

  4. And if you protect your document and allow only Comments - BuiltInDocumentProperties.Security = ReadOnlyExceptAnnotations
    In these two cases you can use Document.ProtectionType property:
    https://docs.aspose.com/words/net/protect-or-encrypt-a-document/

Best regards,