引入命名空间:
using System.Drawing;
以下代码即可实现:
static void PrintScreen() { using (Bitmap bitPic = new Bitmap( width: Screen.PrimaryScreen.Bounds.Width, height: Screen.PrimaryScreen.Bounds.Height)) { using (Graphics gra = Graphics.FromImage(bitPic)) { gra.CopyFromScreen(new Point(0, 0), new Point(0, 0), bitPic.Size); bitPic.Save("D:\\screen.bmp"); bitPic.Dispose(); gra.Dispose(); } } }
标签:using,C#,截取,Dispose,bitPic,gra,new,屏幕 From: https://www.cnblogs.com/cfsl/p/17047475.html