Load a docx by stream

Hello everyone.

I’m trying to load a docx by stream, but I always receive the exception the file is corrupted:
“The document appears to be corrupted and cannot be loaded”

But I can save a copy of this document and open by Microsoft word without errors.
Any idea about this issue?
I have attached the document that I’m trying to load and my code is below:

private Aspose.Words.Document GetDocument(MemoryStream stream)
   var doc = new Aspose.Words.Document(stream); // <-- I got the exception here
   return doc;

Hi Marcelo,

Thanks for your inquiry. We have tested the scenario using latest version of Aspose.Words for .NET 16.1.0 and have not found the shared issue. Please use Aspose.Words for .NET 16.1.0. We have used following code example to test this issue.

// Open the stream. Read only access is enough for Aspose.Words to load a document.
Stream stream = File.OpenRead(MyDir + "doctest.docx");
// 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.

Thanks Tahir.

I have updated Aspose.Words.dll with the latest version and now it’s ok.


Hi Marcelo,

Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.