Document Constructor (String, LoadOptions) |
Opens an existing document from a file. Allows to specify additional options such as an encryption password.
Namespace:
Aspose.Words
Assembly:
Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntaxpublic Document(
string fileName,
LoadOptions loadOptions
)
Public Sub New (
fileName As String,
loadOptions As LoadOptions
)
public:
Document(
String^ fileName,
LoadOptions^ loadOptions
)
new :
fileName : string *
loadOptions : LoadOptions -> Document
Parameters
- fileName
- Type: SystemString
File name of the document to open. - loadOptions
- Type: Aspose.WordsLoadOptions
Additional options to use when loading a document. Can be null.
Exceptions
Remarks
ExamplesExplicitly loads a document as HTML without automatic file format detection.
LoadOptions loadOptions = new LoadOptions();
loadOptions.LoadFormat = Aspose.Words.LoadFormat.Html;
Document doc = new Document(MyDir + "Document.html", loadOptions);
ExamplesShows how to load a Microsoft Word document encrypted with a password.
Document doc;
Assert.Throws<IncorrectPasswordException>(() =>
{
doc = new Document(MyDir + "Encrypted.docx");
});
LoadOptions options = new LoadOptions("docPassword");
doc = new Document(MyDir + "Encrypted.docx", options);
using (Stream stream = File.OpenRead(MyDir + "Encrypted.docx"))
{
doc = new Document(stream, options);
}
See Also