Checking PowerPoint type (ppt or pptx) on-fly

Is it possible? I mean is there some way to detect it from code before creating Presentation or PresentationEx object?
Thank you.

Hello Dear,

You may please use the following code snippet to find whether the given file is PPT or PPTX. Please share with us, if you may feel any problem in understanding the code.

String File="d:\\RectShp1.pptx";

String extension = System.IO.Path.GetExtension(File);

if(extension.CompareTo (".ppt")==0)

MessageBox.Show("Presentation is PPT");

else

MessageBox.Show("Presentation is PPTX");

Thanks and Regards,

I am working with streams so there is no way to me to know the file’s extension… Is there another way except of catch specific exception?

Hello Dear,

I have another work aournd for you that may be used to identify the whether the given presentation is PPT or PTX. But you may need to create PresentationEx object for that and handle the exception.

try{

FileStream fis = new System.IO.FileStream("D:\\Aspose Data\\Adjustingtostudy2.ppt", System.IO.FileMode.Open, System.IO.FileAccess.Read);

PresentationEx Pres = new PresentationEx(fis);

MessageBox.Show("Presentation is PPTX");

}

catch (PptxUnsupportedFormatException unsupExp)

{

MessageBox.Show("Presentation is PPT");

}

Thanks and Regards,

Thanks for your reply.
I think I’ll use this method.