Hi. I made this program to capture the current screen in C#. In Visual Studio 2008, it worked perfectly, but now with VS 2010, I get the following exception: ExternalException - a generic error occured in GDI+ on the line where I save the bitmap:

bmp.Save("screen.jpg");

I have looked everywhere on the Net, but it's always suggested that the problem is in the code. Well it isn't, the code works fine in VS 2008.

I found the problem.
I was using bmp.Save("screens\\screen" + n + ".jpg");
(screens is a non-existing folder to be created)
but when I changed it to bmp.Save("screen" + n + ".jpg"); it worked.

When I used this:
System.IO.Directory.CreateDirectory("screens");
bmp.Save("screens\\screen" + n + ".jpg");
it also worked.

Please mark this thread as solved if you have found an answer to your question and good luck!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.