How to take ScreenShot in C#

To create a screenshot in c# we need to use drawing api of the .net framework

First you have import System.Drawing.Imaging name space with following code...

using System.Drawing.Imaging;

here is the code in C# for screenshot.

int screenWidth = Screen.GetBounds(new Point(0, 0)).Width;
int screenHeight = Screen.GetBounds(new Point(0, 0)).Height;
Bitmap bmpScreenShot = new Bitmap(screenWidth, screenHeight);
Graphics gfx = Graphics.FromImage((Image)bmpScreenShot);
gfx.CopyFromScreen(0, 0, 0, 0, new Size(screenWidth, screenHeight));

bmpScreenShot.Save("test.jpg", ImageFormat.Jpeg);


Comments have been disabled for this content.