Free Support Forum - aspose.com

Determine version of powepoint presentation (ppt or pptx)

Hello everyone,

I need to determine the version of powerpoint presentation file, is it ppt or pptx.

Here is the problem. I use Presentation class to process ppt and PresentationEx to process pptx.
I use file extension to decide which class to use.
But if I change extension of pptx file to ppt, Presentation class will not be able to process such file.

So here is my question: can I determine version of powerpoint file (is it ppt or pptx) not by extension, but discovering the content? Does Aspose provide some API for doing this ?

Thanks a lot for help

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

Thanks for considering Aspose.Slides.

I suggest
that you may try accessing the presentation fist using Presentation class. If
it is PPT then it will be read properly. However, if it turns out to be a PPTX,
then Presentation class throws unsupported file format exception. You can then
catch the exception and using PresentationEx class to access that. Hope it
clears the concept to you.
<o:p></o:p>

Thanks and
Regards,

Thanks for reply. Yes this solution is clear for me.
As I understand Aspose does not provide such presentation file check logic.
So try/catch workaround is the only solution, correct ?

Hi Roman,

Yes, try catch is the solution that can be adopted. Other work around can be checking the extension of the file to be opened and it will also avoid the try catch block and you will be directly accessing the presentation either through Presentation and PresentationEx class directly.

Thanks and Regards,