Friday, 16 March 2018

How to capture desktop screenshot using c# winform application

Description : In this post how to capture desktop screen shot using windows application add below namespace and code for take screen shot.

- Add below namespace for generate image

using System.Windows.Forms;
using System.Drawing.Imaging;

- Add below code for capture image and save in specific directory

Bitmap bitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height); 
Graphics graphics = Graphics.FromImage(bitmap as System.Drawing.Image); 
graphics.CopyFromScreen(0, 0, 0, 0, bitmap.Size); 
bitmap.Save(@"FolderPath", ImageFormat.Jpeg);