using System; using System.Drawing; using System.Windows.Forms; /// /// Saves an image of the screen to the specified path. /// /// /// Path, where output file will be saved at. /// Path of the successfully saved image or errormessage public string ScreenToPicture(string Location) { try { Size currentScreenSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height); Bitmap ScreenToBitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height); System.Drawing.Graphics gGraphics = System.Drawing.Graphics.FromImage(ScreenToBitmap); gGraphics.CopyFromScreen(new Point(0, 0), new Point(0, 0), currentScreenSize); ScreenToBitmap.Save(Location); return Location; } catch (Exception ex) { throw new Exception(ex.Message); } }