C# winform 截屏代码

2021-11-02 15:58:16 浏览数 (1)

代码语言:javascript复制
try
            {
                Image image = new Bitmap(width, height);
                Graphics g = Graphics.FromImage(image);

            g.CopyFromScreen(x, y, 0, 0, new System.Drawing.Size(width, height));     


            string hour = DateTime.Now.Minute.ToString();
            string second = DateTime.Now.Second.ToString();
            image.Save(ScreenshotPath   "\"   hour   "_"   second   ".jpg");
        }
        catch 
        { 

        }




ScreenshotPath------------保存路径
string hour = DateTime.Now.Minute.ToString();
string second = DateTime.Now.Second.ToString();------------------------取当前时间,作为文文件名</pre> 

0 人点赞