I'm doing a windowsService program, which is take screen capture automatically every A sec and set it on dir. When I run it works only one time. How can I make it? Here is my code.
protected override void OnStart(string[] args)
{
timer1_Tick();
}
private void timer1_Tick()
{
string myDir = "c:\\Newfolder\\photo";
System.IO.Directory.CreateDirectory(myDir);
Bitmap bitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width,Screen.PrimaryScreen.Bounds.Height);
Graphics graphics = Graphics.FromImage(bitmap as Image);
graphics.CopyFromScreen(0, 0, 0, 0, bitmap.Size);
string fileName = string.Format(@"c:\Newfolder\photo\Screenshot" +"_" + DateTime.Now.ToString("(dd_MMMM_hh_mm_ss_tt)") + ".png");
bitmap.Save(fileName, ImageFormat.Png);
}