-1

I need this button to run automatic

private void button2_Click(object sender, EventArgs e)
{
    if (File.Exists("c:\\form\\registro " + DateTime.Now.ToString("dd" + "-" + "MM" + "-" + "yyyy") + ".txt"))
    {
        File.Delete("c:\\form\\registro " + DateTime.Now.ToString("dd" + "-" + "MM" + "-" + "yyyy") + ".txt");
        StreamWriter writer = new StreamWriter("c:\\form\\registro " + DateTime.Now.ToString("dd" + "-" + "MM" + "-" + "yyyy") + ".txt", true);
        regravarv =txbEspelho.Text;
        writer.Write(regravarv);

        writer.Close();
    }
    else
    {
        MessageBox.Show("O arquivo registro atual não existe!");
    }
}

closed as unclear what you're asking by c32hedge, alecxe Jan 15 at 17:31

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    What have you tried? – c32hedge Jan 15 at 15:55
0

Try this (time is in miliseconds 5000 = 5 seconds :c) at the end of your loop, you need to wrap your code under a for or foreach loop, so it repeats the number of times you want with a pause of 8 seconds.

System.Threading.Thread.Sleep(8000);
  • It did not work, I need it done. Using type of an onClick – Ronison Matos Jan 13 at 23:59

Not the answer you're looking for? Browse other questions tagged or ask your own question.