LoadOptions Constructor (String)

A shortcut to initialize a new instance of this class with the specified password to load an encrypted document.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntax
public LoadOptions(
	string password
)

Parameters

password
Type: SystemString
The password to open an encrypted document. Can be null or empty string.
Examples
Shows how to load a Microsoft Word document encrypted with a password.
Document doc;

// Trying to open a password-encrypted document the normal way will cause an exception to be thrown
Assert.Throws<IncorrectPasswordException>(() =>
{
    doc = new Document(MyDir + "Encrypted.docx");
});

// To open it and access its contents, we need to open it using the correct password
// The password is delivered via a LoadOptions object, after being passed to it's constructor
LoadOptions options = new LoadOptions("docPassword");

// We can now open the document either by filename or stream
doc = new Document(MyDir + "Encrypted.docx", options);

using (Stream stream = File.OpenRead(MyDir + "Encrypted.docx"))
{
    doc = new Document(stream, options);
}
See Also