我想做一个程序,当它到每个月的1号零点的时候,就执行程序 ,我现在做了一个小测试程序,因为是初学,不太懂,网上找的很久,也没弄明白 ,请大家帮忙 ,我把做的测试小程序发给大家看看,望大家指出问题,谢谢大家
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
if (DateTime.Now.ToString("MM-dd HH:mm:ss") == "01-01 00:00:00")
{
timer1.Start();
}
} private void timer1_Tick(object sender, EventArgs e)
{
this.label1.Text = "程序到点开始运行" ;
}
}
}我这里有两个地方不明白,我的计算机时间没到设定的时间,为什么也开始触发timer1_Tick时间了,请大家帮忙看看,谢谢大家
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
if (DateTime.Now.ToString("MM-dd HH:mm:ss") == "01-01 00:00:00")
{
timer1.Start();
}
} private void timer1_Tick(object sender, EventArgs e)
{
this.label1.Text = "程序到点开始运行" ;
}
}
}我这里有两个地方不明白,我的计算机时间没到设定的时间,为什么也开始触发timer1_Tick时间了,请大家帮忙看看,谢谢大家
{
public partial class Form1 : Form
{
public Form1()
{
timer1.Start();
} private void timer1_Tick(object sender, EventArgs e)
{
if (DateTime.Now.ToString("MM-dd HH:mm:ss") == "01-01 00:00:00")
{
this.label1.Text = "程序到点开始运行" ;
}
}
}
timer1.Start(); 写在加载事件里面