Free Support Forum -

Alternative to Memory Stream


I want to pass or use the byteArary directly to create the Aspose word document.

Right now, Aspose Document class API has only two options - stream, or local file

public Document(Stream stream);

public Document(string fileName);

I dont want to save the data received from the server to local file. I want to pass the byteArary directly to Document object without creating/using the MemoryStream. Is their any alternative appraoch?. Are there any other Stream utilities. Please assist.

Right now In my Asp.Net MVC 4.0 project (C#), I am creating the Aspose document as follows:

byte[] byteArray = DownloadTestFileStream();

Stream stream = new MemoryStream(byteArray);

doc = new Document(stream);

Hi Santosh,

Thanks for your inquiry. You are loading document from byte array into Aspose.Words DOM correctly in your code. You can not pass a byte array to Document’s constructor. Please read more about Document’s constructor from here:

You may return document’s stream from your DownloadTestFileStream method and load that stream into Aspose.Words DOM. Please let us know if you have any more queries.