Detect if Word Document is Encrypted using C# .NET - Anyway to Open Password Protected Encrypted Word Document DOCX?

Can I open this file that was blocked even from reading using password without password? I just need to open (13.7 KB)


Your document has no protection but it is encrypted that is why Microsoft Word asks for a password prior opening it. You should simply specify the password to open the encrypted document using Aspose.Words. If you do not know the password, I am afraid, you will then not be able to open this document by using Aspose.Words. Aspose.Words will throw the following error upon loading such documents without specifying password:

Aspose.Words.IncorrectPasswordException: The document password is incorrect

So, there is no way to open encrypted document without password. However, you can only check that this document is encrypted or not by using the following simple code:

FileFormatInfo info = FileFormatUtil.DetectFileFormat("E:\\karta_izo_parole.docx");
Console.WriteLine("IsEncrypted = " + info.IsEncrypted);

If we can help you with anything else, please feel free to ask.

1 Like

Thanks a lot. Especially for code validation of encryption