Document Constructor (String)
Opens an existing document from a file. Automatically detects the file format.

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.11
Syntax
public Document(
	string fileName
)

Parameters

fileName
Type: SystemString
File name of the document to open.
Exceptions
ExceptionCondition
UnsupportedFileFormatExceptionThe document format is not recognized or not supported.
FileCorruptedExceptionThe document appears to be corrupted and cannot be loaded.
ExceptionThere is a problem with the document and it should be reported to Aspose.Words developers.
IOExceptionThere is an input/output exception.
IncorrectPasswordExceptionThe document is encrypted and requires a password to open, but you supplied an incorrect password.
ArgumentExceptionThe name of the file cannot be null or empty string.
Examples
Opens a document from a file.
// Open a document. The file is opened read only and only for the duration of the constructor.
Document doc = new Document(MyDir + "Document.doc");
See Also