Free Code Snippets in C#, Net Framework, Office 365, ASP.Net,WPF, Visual Studio, SQL Server, Antivirus free
#

C #: Windows ScreenShot save as file, Windows Graphics, Desktop

 

This application in Windows WPF saves the current monitor as a screenshot in a .png file

 

 

Video Tutorial

 

This application in Windows WPF saves the current monitor as a screenshot in a .png file

 

 

 

C # Code in WPF, Win32

private void save_ScreenShot_as_File()

        {

            //------------< save_ScreenShot_as_File() >------------

            //*add reference System.Drawings

            //*using System.Drawing;

 

            //< init >

            String filename = "ScreenCapture-" + DateTime.Now.ToString("ddMMyyyy-hhmmss") + ".png";

            //</ init >

 

            //< size >

            int screenLeft = (int) SystemParameters.VirtualScreenLeft ;

            int screenTop = (int) SystemParameters.VirtualScreenTop;

            int screenWidth = (int) SystemParameters.VirtualScreenWidth;

            int screenHeight = (int) SystemParameters.VirtualScreenHeight;

            //</ size >

 

            Bitmap bitmap_Screen = new Bitmap(screenWidth, screenHeight);

            Graphics g = Graphics.FromImage(bitmap_Screen);               

           

            //-< get ScreenShot >

            //*into bitmap as graphics

            g.CopyFromScreen(screenLeft, screenTop, 0, 0, bitmap_Screen.Size);

            //-</ get ScreenShot >

 

            //< save bitmap >

            bitmap_Screen.Save("C:\\_Daten\\Desktop\\Backgrounds\\" + filename);

            //</ save bitmap >

            

            //------------</ save_ScreenShot_as_File() >------------

        }

 

 

namespace

One must integrate Systems.Drawings

using System.Drawing; //for bitmap, screenshot

Mobile
»
WPF / UWP: Canvas with relative positions and sizes
»
C #, WPF, UWP: ScreenShot to save an app or window area as a file
»
C #: Windows ScreenShot save as file
»
WPF Color Picker on Color Cube
»
WPF: Draw ColorWheel in C# by drawing Lines
»
WPF: Snap In to Next Lines of Elements
»
WPF Code: Usercontrol with customizable size at runtime
»
WPF: Save the background of a Windows app as a ScreenShot
»
WPF, UWP: Create transparent app window
»
WPF: Determine the relative position of an element

.

Contact for Jobs, Project Requests: raimund.popp@microsoft-programmierer.de