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

Free Support Forum - aspose.com

Can't read MSCDFileSystem with Slides 15.6.0 opening ppt or pptx from filestream

I am getting a “Can’t read MSCDFileSystem” when opening up a presentation with aspose slides 15.6.0 from a filestream. here is my example code plus I attached a sample doc that you can use, but it seems to not work with any ppt or pptx. This code worked with slides 8.1. all I am trying to do is open the presentation and get all the text from it.



I have other code where I am starting from a byte array, converting to a memory stream, and it works fine. I also tried converting the filesstream to a memorystream and got the same error.



private static string GetPptContent(Stream fileStream)

{

using (fileStream)

{

var powerpointPresentation = new Presentation(fileStream);



var extractedText = new StringBuilder();



//Get an Array of ITextFrame objects from all slides in the powerpoint, ignoring the master slide

ITextFrame[] textBoxes = Aspose.Slides.Util.SlideUtil.GetAllTextFrames(powerpointPresentation, false);



foreach (ITextFrame textBox in textBoxes)

{

foreach (Paragraph paragraph in textBox.Paragraphs)

{

foreach (Portion portion in paragraph.Portions)

{

extractedText.Append(portion.Text);

}

}

}

return extractedText.ToString();

}

}

Update: Actually the issue seems to be that I am using a stream returned from a WCF call which is actually a networkstream, not a filestream. If I take the results of the WCF call and save it to a file, then open up that file in a filestream, then this code works as expected. So there must be something in aspose slides that doesn’t like a networkstream. Along with that MSCDFileSystem error was an inner exception “Index was outside the bounds of the array.”. This error does not occur in aspose word or cells. its specific to slides.

is there something I could do in the meantime to get this to work from the networkstream that is being returned from WCF.

Hi Kirk,

Thanks for getting back to us. I have observed the requirements shared by you and like to share that you can also try the ByteInput stream as well while loading the presentation. Importantly, you need to set the stream position to 0 before loading that using Presentation object exposed by Aspose.Slides for .NET. I hope the shared information will be helpful. Please share, If I may help you further in this regard.

Many Thanks,

Can you provide an example of this ByteInput stream you are referring to? c# code.

you mean creating a memory stream from a byte? we only get that networkstream from our wcf service. or maybe converting that to a byte and then back to a memory stream? idk, I did try doing a copyto from the networkstream to a memorystream and got the same error. I think because at its base the memorystream doesn’t support something that your ppt code is expecting. its weird because this same networkstream works perfectly fine with aspose word and aspose cells, so I assume that means that apose slides was coded different internally on how it handles streams than the other two?

Hi Kirk,


I have worked with the presentation file shared by you by loading that using file stream and it worked on my end. I have tried using the following sample code using Aspose.Slides for .NET 15.6.0 on my end. The issue does not seem to be related to Aspose.Slides as if I load the presentation shared by you using stream via Aspose.Slides there is no issue. For assurance, I suggest you to please write your networkstrem as a presentation file and then load that using PowerPoint and Aspose.Slides to see if the file is in good health or not.

private static string GetPptContent(Stream fileStream)
{
using (fileStream)
{
fileStream.Position = 0;
var powerpointPresentation = new Presentation(fileStream);

var extractedText = new StringBuilder();

//Get an Array of ITextFrame objects from all slides in the powerpoint, ignoring the master slide
ITextFrame[] textBoxes = Aspose.Slides.Util.SlideUtil.GetAllTextFrames(powerpointPresentation, false);

foreach (ITextFrame textBox in textBoxes)
{
foreach (Paragraph paragraph in textBox.Paragraphs)
{
foreach (Portion portion in paragraph.Portions)
{
extractedText.Append(portion.Text);
}
}
}
return extractedText.ToString();
}
}
public static void TestStream()
{
FileStream fs = new FileStream(“C:\Presentations\Top 10 COBRA.ppt”, FileMode.Open);
GetPptContent(fs);
}

Many Thanks,

I was able to get this to work by copying the wcf stream to a memory stream and then setting position to 0. I thought I had tried that before, but maybe I missed the position setting.

This exact method has worked with wcf streams and aspose slides since last year with slides 8.1, and only started failing as soon as we upgraded to latest version. This tells me that something has changed in slides that is causing this. I did notice that our code for doing this with apose words and aspose cells also had this conversion to a memory stream, so maybe this is just the better route. kinda defeats the purpose of using a stream in the first place if I have to copy it another stream, but at least it works now.

just for reference, this was the entire error plus inner exception on what I was getting.

An exception of type ‘Aspose.Slides.PptReadException’ occurred in Aspose.Slides.dll but was not handled in user code

this is the full error with inner exception if it helps:

{Aspose.Slides.PptReadException: Can’t read MSCDFileSystem. —> System.IndexOutOfRangeException: Index was outside the bounds of the array.
at .()
at …ctor(Stream )
at .()
at .()
at …ctor(Stream )
at ​ .(Stream )
at ​ …ctor(Stream )
at .(Stream )
— End of inner exception stack trace —
at .(Stream )
at Aspose.Slides.Presentation.(Stream )
at Aspose.Slides.Presentation…ctor(Stream stream, LoadOptions loadOptions)
at Aspose.Slides.Presentation…ctor(Stream stream)
at Zywave.Shared.OfficeEngine.Services.AsposeHelper.GetPptContent(Stream fileStream) in c:\Projects\Services Shared\OfficeEngine\Trunk\Data\AsposeHelper.cs:line 113
at Zywave.Shared.OfficeEngine.Services.AsposeHelper.GetFileContent(String fileName, StreamingFileDownloadMessageResponse fileStream) in c:\Projects\Services Shared\OfficeEngine\Trunk\Data\AsposeHelper.cs:line 47
at Zywave.Shared.OfficeEngine.Data.OtherServices.GetDocumentText(Guid fileId, String fileName) in c:\Projects\Services Shared\OfficeEngine\Trunk\Data\OtherServices.cs:line 56
at Zywave.Shared.OfficeEngine.Services.ElasticService.GetDocumentText(Guid fileId, String fileName) in c:\Projects\Services Shared\OfficeEngine\Trunk\Services\ElasticService.cs:line 42
at SyncInvokeGetDocumentText(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)}

Hi Kirk,

Its good to hear that things are some how working on your end. I have also discussed the issue of loading WCF stream using Presentation object. An issue with ID SLIDESNET-36671 has been created in our issue tracking system to further investigate the issue on our end. We will share the feedback with you in this regard as soon as it will be shared by our product team.

Many Thanks,