@truongminhlong,
I have observed your requirements and like to share that if the document is encrypted (no matter XLSX, DOCX or PPTX) and you load that using Aspose.Slides without providing any password, Aspose.Slides will throw InvalidPasswordException in that case. You can try load the document with password protection without providing valid password and InvalidPasswordException will be thrown that you need to catch and handle. Inside catch block you need to again load the document with valid password and Aspose.Slides will throw PptxUnsupportedFormatException on loading a password protected XLSX or DOCX with valid password provided. This way you can handle loading the valid file format supported files. Please try using following sample code to serve the purpose.
public static void DetectFileFormat()
{
try
{
String path = @"C:\Aspose Data\sampleFiles\";
Presentation pres = new Presentation(path + "test.docx");
}
catch (InvalidPasswordException ex)
{
String s = ex.StackTrace;
try
{
String path = @"C:\Aspose Data\sampleFiles\";
Aspose.Slides.LoadOptions opts = new Aspose.Slides.LoadOptions();
opts.Password = "test";
Presentation pres = new Presentation(path + "test.docx", opts);
}
catch (PptxUnsupportedFormatException e)
{
String ssd = e.StackTrace;
}
catch (Exception exx)
{
String ss = exx.StackTrace;
}
}
catch (PptxUnsupportedFormatException e)
{
String ssd = e.StackTrace;
}
}