Opening Word documents

Hi,
I am using Aspose.Words assembly in .NET to manage Word documents. Can I open an existing word document? I see a Save() method on Document class that saves the document, but I do not see any method to Open the document. Can I open a document that is stored in MemoryStream object without first saving it to disk?
Thanks,
Mahendra

This message was posted using Aspose.Live 2 Forum

Dear Mahendra,

Thank you for your question.
Using Aspose.Words you can open an existing document by simple way:
from a memory stream:

// Open the stream. Read only access is enough for Aspose.Words to load a document.
Stream stream = File.OpenRead(MyDir + "Document.doc");
// Load the entire document into memory.
Document doc = new Document(stream);
// You can close the stream now, it is no longer needed because the document is in memory.
stream.Close();

or direct from existing file:

Document doc = new Document(MyDir + "Document.doc");

For more information please refer to: https://reference.aspose.com/words/net/aspose.words/document/

Hope this helps.

Thanks for your reply. What I meant was, can I open an existing word doc file that is saved on the disk in MS word software that is installed on the machine and display it to the user?

Hi There,
Thanks for your inquiry.
Sure, you can use the Process.Start method as shown below. This will open the document in the default viewer, which should be MS Word.

// Open file in MS Word
System.Diagnostics.Process.Start(fileName);

Thanks,