C# - Filesystemwatcher to enable Timer
<p><strong>Hello All,</strong> </p>

<p>//Pleas i have a simple Problem. I need, when Filesystemwatcher sees the File -after fsw start the Timer for Closing Application (Application will be Closed after 2 second, when is file created)// </p>

<p><strong>Thank you user "Never Quit" *</strong></p>

<p>Finaly i Have this "easy" Code :-) </p>

<pre><code> public partial class Form1 : Form
{

    System.Timers.Timer casovac = new System.Timers.Timer();
    int totalSeconds = 0;

    public Form1()
    {

        InitializeComponent();
        casovac.Interval = 1000;
        casovac.Elapsed += new System.Timers.ElapsedEventHandler(cas_elapsed);

    }
    void cas_elapsed(object sender, System.Timers.ElapsedEventArgs e)
    {
          totalSeconds++;

        if (totalSeconds == 3) 
        {
            casovac.Stop();
            Application.Exit();
        }
    }

    private void Form1_Load(object sender, EventArgs e)
    {

        FileSystemWatcher fsw = new FileSystemWatcher();

        fsw.Path = Application.StartupPath + "\\OUT\\";
        fsw.Filter = "file.exe";
        fsw.IncludeSubdirectories = true;
        fsw.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
        | NotifyFilters.FileName | NotifyFilters.DirectoryName;
        fsw.Changed += new FileSystemEventHandler(fsw_changed);
        fsw.Created += new FileSystemEventHandler(fsw_changed);
        fsw.EnableRaisingEvents = true;
    }
    private void fsw_changed(object source, FileSystemEventArgs e)
    {

        casovac.Start();         
    }




}
</code></pre>

<p>}</p>

<p>But Thank you All ;-)</p>
