A generic error occurred in GDI+.

Hi guys, I'm trying to capture screen shots from my machine every so many seconds, and I'm running into a GDI error [ that being the one in the subject]

Here is my code

[code]
Bitmap bmpScreenshot = new Bitmap(230, 150, PixelFormat.Format32bppArgb);
Graphics gfxScreenshot = Graphics.FromImage(bmpScreenshot);
Size thesize = new Size(230, 150);
gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, thesize, CopyPixelOperation.SourceCopy);
bmpScreenshot.Save(@"C:\test.png", ImageFormat.Png);
[/code]

Any ideas?

[601 byte] By [BryanKardisco] at [2007-12-22]
# 1

Give that that code works just fine for me in C# Express you’ll have to be more specific on the specifics of your problem.

What kind of application is this running within? On what line/instruction is the Exception being thrown because of?

BrendanGrant at 2007-8-30 > top of Msdn Tech,.NET Development,.NET Base Class Library...
# 2
I'm sorry, seems the problem was me. My machine at work has all of these security measures on it to keep people from doing stupid things . Found out that I can't save to the C:/ folder but can to my desktop stupid rules
BryanKardisco at 2007-8-30 > top of Msdn Tech,.NET Development,.NET Base Class Library...

.NET Development

Site Classified