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

Free Support Forum - aspose.com

Need exception for case when password is incorrect

Hi,


I need to determine in code that user provided incorrect password and ask to enter correct one. For Aspose.Word and Aspose.Cell all is fine (in past you added such exception type). But Aspose.Slide does not allow me easily determine if password is protected. I need to use such ugly code:
//ppt, pot
(ex.GetType().FullName == “Aspose.Slides.PptReadException” && ex.InnerException != null && ex.InnerException.GetType().FullName == “System.ApplicationException” && ex.InnerException.Message == “Wrong password.”)
//PPT2007 with wrong password specified
|| (ex.GetType().FullName == “Aspose.Slides.Pptx.PptxReadException” && ex.Message == “Invalid password.”)
//PPT2007 without password specified
|| (ex.GetType().FullName == “System.Exception” && ex.Message.StartsWith(“Presentation is encrypted”))

Would you be so kind to add new Exception type when password is incorrect for presentation?

Many thanks,
Alex Shloma

Hi Alex,


Please try using the following sample code to check if the presentation is password protected or not. Please share, if I may help you further in this regard.

public static void checkPass()
{
try{
String path=“D:\Aspose Data\”;
PresentationEx pres=new PresentationEx(path+“passwordprotected.pptx”);
}
catch(Exception e)
{
String tes=e.Message;
if(tes.Contains(“Presentation is encrypted”))
{
Console.WriteLine(“Presentation is encrypted…”);
}
}
}

Many Thanks,

Hi Mudassir,


So you propose me to check each exception message with Contains?
if(tes.Contains(“Presentation is encrypted”)) …
if(tes.Contains(“Invalid password”)) …
if(tes.Contains(“Wrong password”)) …
Is there a guarantee that string always will be English?

In past you had the same situation with Cells, but you’ve added special exception. It is not good practice to determine exception by Message string, for this purposes people creates different exception types.
Do you agree that FileNotFoundException(“File blahBlah was not found”) is better than Exception(“File not found. blahBlah”)?

Thank you,
Alex Shloma

Hi Alex,


I feel for different language on your machine the message will be different. It was a work around approach that could be adopted for the time being. I have created an issue with ID SLIDESNET-34129 in our issue tracking system as new feature request to provide the requested exception method. This thread has been linked with the issue so that you may be automatically notified once the issue will be resolved.

We are sorry for your inconvenience,

Many thanks!


Best regards,
Alex Shloma

Hi,


Do we have any news about this issue?

Thank you,
Alex Shloma

Hi Alex Shloma,


Thanks for getting back to us.

I have verified the issue status from our issue tracking system and regret to share that that issue is still unresolved. However, I have raised the priority of the issue to High and have also requested our development team to kindly schedule it for investigation and resolution.

We are sorry for your inconvenience and will share the good news with you as soon as the support will be included in Aspose.Slides.

Many Thanks,