Document Class Save Method cannot save to MemoryStream?

Hi,
Hello , Save method(Document) cannot save to MemoryStream. Please see my code.

MemoryStream mStream = New MemoryStream();
var document = new Document(file);
document.Save(mStream, SaveFormat.Xps);
byte[] data = new byte[mStream.Length];
using(mStream)
{
    mStream.Read(data, 0, data.Length);
}

Thanks,
Andy Huang

Hi

Thanks for your inquiry. Could you please attach your input document here for testing? I will check the problem on my side and provide you more information.
Best regards,

Error message: Cannot find central directory
Thanks.

Hi
Thank you for additional information. I cannot reproduce the problem on my side. I used the latest version of Aspose.Words for testing. You can download it from here:
https://releases.aspose.com/words/net
Also, you should make a small modification in your code (see the highlighted line of code)

MemoryStream mStream = new MemoryStream();
var document = new Document(@"Test001\test.docx");
document.Save(mStream, SaveFormat.Xps);
mStream.Position = 0;
byte[] data = new byte[mStream.Length];
using(mStream)
{
    mStream.Read(data, 0, data.Length);
}

This is needed to read the stream from the beginning.
Best regards,