Click here to Skip to main content
15,917,456 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I know how to take a Screen Shots through Programing but i want to take ScreenShots of the Exceptions Screen appear runtime? Is it possible to do? please Suggest me...Thanks in Advance

Bitmap bitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);

Graphics graphics = Graphics.FromImage(bitmap as Image);

graphics.CopyFromScreen(0, 0, 0, 0, bitmap.Size);

bitmap.Save("c:\\screenshot.jpeg", ImageFormat.Jpeg);.
Posted

1 solution

It will probably work - but you can't put it into your application! It's an exception - and if you are seeing the message, that means that your program has failed to handle the problem, and has effectively crashed. So no part of your application is going to work to take the screen shot. You could put it in a separate UI free application and pin that to a hot key sequence in Windows though.

BTW: Don't try to write to the root of the boot drive - it won't work in most cases on Vista and above because you need admin privileges to write to that folder. Use My documents or allow the user to set the folder - a "Save as" dialog would be a good idea.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900