We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Creating Presentation from MemoryStream

I am trying to open a presentation from a MemoryStream. I create the MemoryStream from a byte array read from a Database. When trying to create the presentation I recieve "Unable to read entire header; 0 bytes read; expected 512 bytes" I can write the same stream out to the response stream and open the PPT file.


MemoryStream str = new MemoryStream();

fileBytes = Section.getSlides( sectionID ); //this is the byte array from the database.

str.Write( fileBytes , 0 , size );

//works with lower line commented out! Uncommented throws an error.

Aspose.Slides.Presentation SlideSet = new Aspose.Slides.Presentation( str );

HttpContext.Current.Response.ContentType = "application/vnd.ms-powerpoint";

Response.AddHeader( "Content-Disposition" , "attachment;filename=Values Presentation" );

str.WriteTo( Response.OutputStream ); // the stream is fine!



I am using version of the Aspose.Slide dll - unlicensed at this point.

Am I missing something?


Updated Information:

I am able to Create a Presentation Object with a FileStream linking to the same file on disk, but not with the MemoryStream opening the file from the database.

Should I be able to use MemoryStream?


Before using MemoryStream set its position to 0 e.g.

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

ms.Postion=0; //ms is MemoryStream object

Presentation pres=new Presentation(ms);