I have properly and made the EnableRaisingEvents to false, yet it raises events, here is how I'm doing it:
private void button2_Click(object sender, EventArgs e)
{
_watcher.EnableRaisingEvents = false;
_watcher.Changed -= new FileSystemEventHandler(InitList);
_watcher.Dispose();
listBox1.Items.Add("Stopped Monitoring Directory " + textBox2.Text);
listBox1.SelectedIndex = listBox1.Items.Count - 1;
textBox2.Enabled = true;
textBox3.Enabled = true;
button1.Enabled = true;
button3.Enabled = true;
button4.Enabled = true;
}
Is there anything else that needs to be done, maybe I'm missing out here. Please advise. http://pastebin.com/yEaffBxP
I see this already, you effectively have created 2 file watchers. One is here
private static FileSystemWatcher _watcher = new FileSystemWatcher();
second - later in
WatchFile()
That should solve it