Load a password-protected document
Leave feedback
To open a password-protected document, create a LoadOptions instance with the file format and set the Password property.
using GroupDocs.Markdown;
var loadOptions = new LoadOptions(FileFormat.Docx)
{
Password = "secret"
};
// Static one-liner
string markdown = MarkdownConverter.ToMarkdown("protected.docx", loadOptions);
File.WriteAllText("load-password-static.md", markdown);
protected.docx is a sample file used in this example. Click here to download it.
**Confidential Memo**
From: Meridian Outdoor Co. — Strategy Team
Date: 2026-01-15
Subject: FY2026 M&A Targets
[TRUNCATED]
using GroupDocs.Markdown;
var loadOptions = new LoadOptions(FileFormat.Xlsx)
{
Password = "secret"
};
using var converter = new MarkdownConverter("protected.xlsx", loadOptions);
converter.Convert("load-password-instance.md");
protected.xlsx is a sample file used in this example. Click here to download it.
## Expenses
| Date | Vendor | Category | Amount |
| --- | --- | --- | --- |
| 2026-01-02 | Pacific Freight | Shipping | $2,450.00 |
| 2026-01-05 | Cedar Packaging | Materials | $1,320.50 |
| 2026-01-08 | Highline Textiles | Materials | $8,940.00 |
| 2026-01-12 | Portland Electric | Utilities | $680.25 |
| 2026-01-14 | Backcountry Co-op | Events | $1,200.00 |
| 2026-01-17 | Ridge Media | Marketing | $5,400.00 |
[TRUNCATED]
If the password is missing or incorrect, a DocumentProtectedException is thrown. You can catch it to display a user-friendly message:
using GroupDocs.Markdown;
try
{
string markdown = MarkdownConverter.ToMarkdown("protected.docx");
}
catch (DocumentProtectedException ex)
{
Console.WriteLine($"Cannot open document: {ex.Message}");
}
protected.docx is a sample file used in this example. Click here to download it.
Cannot open document: The document password is incorrect.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.