FileSystemWatcher Inconsistency

S

Soulless

Hi, I implemented the FileSystemWatcher in an application and on my XP
system it works fine. If I add a file to a directory, it will enable
a button and disable if removed.

On another XP system it does not work in a consistent manner. When
file is created, the button does not enable.

I am wondering about this behaviour and if there is a possible known
issue.. perhaps I am not implementing something correctly.

Here is an example of my code:

// Watch for created files
FileSystemWatcher fileCreatedWatcher = new
FileSystemWatcher(@textBoxWorkingFolder.Text);
// type of change to watch for
fileCreatedWatcher.NotifyFilter = NotifyFilters.FileName;

// delegate to handle the event
fileCreatedWatcher.Created += new
FileSystemEventHandler(this.OnFileCreated);

// begin watching
fileCreatedWatcher.EnableRaisingEvents = true;

Seems simple enough, but only works for me currently.
 
R

Rene

I remember reading that the FileSystemWatcher is kind of buggy but I would
think that the monitoring that you are doing is simple enough.

I guess the question would be, are you comparing apples to apples? Same
folder path? Same file name, size etc etc?
 
G

Guest

Is the only test you have for the event being raised that the button is
enabled? If so, I would log a message of the file system watcher event
somewhere. Also is there some kind of trap regarding the file contents
before the button is enabled? Could file permissions be an issue?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top