My application successfully detects the specific file I want to detect but the messagebox always showing not only once but many times I dont know what is wrong.
Side question is this a good way of always checking if a certain file exists? or there is more better and accurate way? if there is any suggestions or link will be a great help . Thanks!
Here is my code:
private void Form1_Load(object sender, EventArgs e)
{
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
if (File.Exists(patch_to_checked))
{
MessageBox.Show("File Found!");
timer1.Stop();
}
}
You should stop the timer as soon as you enter the function. Otherwise, the timer is ticking while the user is moving the cursor to the button to dismiss the message box: