User Tools

Site Tools

blog:2023-06-21_c_full_screen_dump_to_file



2023-06-21 C#: Full Screen Dump to File

  • This code piece capture screen and save to c:\temp\ folder
  •         private void MENU_ScreenDump()
            {
                try
                {
                    String _str = DateTime.Now.ToString("yyMMdd-HHmmss");
                    Rectangle bounds = Screen.PrimaryScreen.Bounds;
                    using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
                    using (Graphics g = Graphics.FromImage(bitmap))
                    {
                        g.CopyFromScreen(new Point(bounds.Left, bounds.Top), Point.Empty, bounds.Size);
                        bitmap.Save("C://temp//screen-dump-" + _str + ".jpg", ImageFormat.Jpeg);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

TAGS

  • 64 person(s) visited this page until now.

Permalink blog/2023-06-21_c_full_screen_dump_to_file.txt · Last modified: 2023/06/21 17:41 by jethro

oeffentlich