473,405 Members | 2,310 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

FileSystemWatcher Inconsistency

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.

Oct 19 '07 #1
2 1696
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?
"Soulless" <dg*******@gmail.comwrote in message
news:11**********************@z24g2000prh.googlegr oups.com...
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.

Oct 19 '07 #2
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?

"Rene" wrote:
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?
"Soulless" <dg*******@gmail.comwrote in message
news:11**********************@z24g2000prh.googlegr oups.com...
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.


Oct 20 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Troy Murphy | last post by:
How do I prevent the FileSystemWatcher event to keep firing while the file is being created? When copying a file to the watched folder, the event fires a dozen or more times! Also, the...
7
by: Allen Anderson | last post by:
I'm trying to figure out a way to catch when a file has been written to a directory. I currently have it where I can catch when the file begins writing, but this isn't helpful as I need to know...
2
by: Jet Leung | last post by:
Hi all, I had made a program to watching files in my directory. I had used a instance of FileSystemWatcher to do my work.And I had add some events of the FileSystemWatcher , for example onChange,...
13
by: David | last post by:
I have been working on trying to write a directory watcher service. One of the requirments is that it be able to watch multiple directories, not sub directories of one parent directory, but just...
3
by: Stampede | last post by:
Hi, I want to use the FileSystemWatcher in a Windows Service. I read an article, where the author created the FileSystemWatcher object in a seperate thread and when the event is fired, he started...
20
by: J-T | last post by:
We are working on an asp.net application which is a 3-tier application.I was aksed to create a component which monitors a folder and gets the file and pass them to a class library in our business...
12
by: ljh | last post by:
Has anyone else noticed that the FileSystemWatcher raises the changed event twice when a file is changed? Do you have any idea why this is the case?
5
by: Goran Djuranovic | last post by:
Hi all, I have a file system watcher service that works fine on a local hard drive, but will not work across the network. I tried both: mapping the drive and "\\..." path both no luck. I don't...
5
by: =?Utf-8?B?Sm9obiBT?= | last post by:
I am trying to find out if there is a way to tell if there is already a filesystemwatcher (created by a webservice) monitoring a folder. I have a webservice that creates a filesystemwatcher,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.