using System;
using System.IO;
using System.Drawing;
using System.Windows.Forms;
namespace CS_WinShot
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
try {
const string targetFilder = @"C:\cs_winshot\";
string[] fileList = Directory.GetFiles(targetFilder, "*.png");
//http://dobon.net/vb/dotnet/graphics/screencapture.html
var bmp = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
var g = Graphics.FromImage(bmp);
g.CopyFromScreen(new Point(0, 0), new Point(0, 0), bmp.Size);
g.Dispose();
//http://www.atmarkit.co.jp/fdotnet/dotnettips/116formatint/formatint.html
string wk = String.Format("{0:D5}", fileList.Length);
bmp.Save(Path.Combine(targetFilder, wk + ".png"));
}
catch (Exception EX) {
MessageBox.Show(EX.Message);
}
finally {
this.Close();
}
}
}
}