1 public static void TakeScreenshot()
2 {
3 Bitmap bmp;
4 Graphics fx;
5
6 bmp = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
7 Screen.PrimaryScreen.Bounds.Height,
8 System.Drawing.Imaging.PixelFormat.Format32bppArgb);
9
10 fx = Graphics.FromImage(bmp);
11
12 fx.CopyFromScreen(Screen.PrimaryScreen.Bounds.X,
13 Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size,
14 CopyPixelOperation.SourceCopy);
15
16 String fileName = DateTime.Now.Ticks.ToString();
17
18 bmp.Save(fileName, System.Drawing.Imaging.ImageFormat.Png);
19 }