I am using C # in Visual Studio 2010 with framework 4.0.
In my project in two different forms, there are two FileSystemWatcherwith the property EnableRaisingEventset to false. If I close Visual Studio when I open it again, I get FileSystemWatchera EnableRaisingEventvalue in the property true.
In both of my forms, the constructor file has the following code:
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.fileSystemWatcher1 = new System.IO.FileSystemWatcher();
((System.ComponentModel.ISupportInitialize)(this.fileSystemWatcher1)).BeginInit();
this.SuspendLayout();
this.fileSystemWatcher1.Filter = "my_filter";
this.fileSystemWatcher1.NotifyFilter = System.IO.NotifyFilters.LastWrite;
this.fileSystemWatcher1.SynchronizingObject = this;
this.fileSystemWatcher1.Changed += new System.IO.FileSystemEventHandler(this.fileSystemWatcher1_Changed);
}
The property is EnableRaisingEventnot set, but it is by default false.
Any idea why I get this weird behavior?
change
I followed the Virtlink suggestion by adding the following line of code:
this.fileSystemWatcher1.EnableRaisingEvents = false;
, , ( , , fileSystemWatcher1) :
Visual Studio 2012 ( Framework 4.0), . , VS10.
?