I am getting some odd behaviour with the FileSystemWatcher object. Please refer to my code snippets below:
Whenever I create a new XML file in the specified directory the file name get printed twice as opposed to a single time. Tried setting a breakpoint in my eventhandler and it looks like the function is getting called twice which doesnt explain things.
What I am trying to achieve is to read the contents of the newly created and then delete it. So if the function get called twice,it will through up a filenotfound exception the second time. Came across this oddy while testing. What am I missing in here.
static void Main(string args)
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = @"C:\XmlFiles";
watcher.Filter = "*.xml";
watcher.Created += new FileSystemEventHandler(FileCreated);
watcher.EnableRaisingEvents = true;
static void FileCreated(object sender, FileSystemEventArgs e)