In Asp.net (c#),i’m not able to catch exception(FileNotFoundException) properly… i don’t know the reason..Actually File s not there..But catch statement fails to catch the exception..
here is the code..
try
{
System.Drawing.Image imgg1 = System.Drawing.Image.FromFile(Server.MapPath("").ToString() + "\\images\\img1.jpg");
}
catch (FileNotFoundException)
{
Response.Write("<script>alert('Please Select and upload Student's Photo');</script>");
}
Are you sure that’s the exception your getting?
You should try to replace the FileNotFoundException to just Exception and check what exception is being trown.
EDIT:
Q1: In the debug mode, is the code actually entering the catch session?
Could you rebuild (Ctrl+Shift+B in Visual Studio) that code?
Your actually writing a code that will fail
there’s an ending quote in here:
See in the sintax highlighter
replace for this