---
title: "Capture Screenshots Program in CSharp .NET"  
description: "/* Style Definitions */   table.MsoNormalTable  	{mso-style-name:\"Table Normal\";  	mso-tstyle-rowband-size:0;  	mso-tstyle-colband-size:0;  	mso-st"  
author: "Anonymous User"  
published: 2010-07-30  
updated: 2020-03-04  
canonical: https://www.mindstick.com/articles/48/capture-screenshots-program-in-csharp-dot-net  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Capture Screenshots Program in CSharp .NET

Capturing screen through C# is just like pressing Print Screen button on keyboard.\

## Example

```
//adding Imaging name spaceusing System.Drawing.Imaging;        private void timer1_Tick(object sender, EventArgs e)        {            string filename;            string dir;            try            {                dir = "C:\\screen" + DateTime.Today.Day.ToString();                filename = dir + "\\screen" + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + ".jpg";                if (!Directory.Exists(dir))                    Directory.CreateDirectory(dir);                //Set the bitmap object to the size of the screen                Bitmap screenShot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);                 // Take the screenshot from the upper left corner to the right bottom corner                Graphics screenGraphics = Graphics.FromImage(screenShot);                screenGraphics.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);               // Save the screenshot                screenShot.Save(filename, ImageFormat.Jpeg);            }            catch (Exception ex)            {                MessageBox.Show(ex.Message);            }                    }         private void Form1_Load(object sender, EventArgs e)        {                        timer1.Interval = 1000;            timer1.Enabled = true;        }
```

##### Screenshot

![Capture Screenshots Program in CSharp .NET](https://www.mindstick.com/mindstickarticle/d6e435cc-e0e3-4e26-8f3a-15cfb0fd80ba/images/ff554352-ea4a-4d5a-9735-c24542d940ce.png)

\

---

Original Source: https://www.mindstick.com/articles/48/capture-screenshots-program-in-csharp-dot-net

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
