Filesystemwatcher change event

Asked By vishal
31-Aug-10 10:51 PM
Earn up to 0 extra points for answering this tough question.

Hi,

  Plzzzzzz help......
    I had created a windows service. When I copy a new file into specified folder FSW created event is working perfectly for me.
1) But when I write a FSW Changed event and trying to copy a new file, Created event as wellas changed event(3 times) fires.
In changed event i check with the condition If e.ChangeType = WatcherChangeTypes.Changed, but still it is executing inside that block of code. 
2) When I am copying a file in to a folder where there is already a file with same name exist. so it overwrites the existing file.
After overwriting the changed event fires multiple time.

pls help me anyone to get  a perfect solution. 

  re: Filesystemwatcher change event

samjayander thiagarajan replied to vishal
01-Sep-10 01:23 AM
Hi,

This is the behavior of the FileSystemWatcher. It reacts on each event and the event naturally corresponds to the application that creates the file.

For example, in WinZip, when you create a Zip file, it will first create a temporary file and then it will create the original file. so each application behaves differently while creating a file.

So, what is your requirement?? You should tailor your methods in subscribing and filtering the events based on your requirement.  

Coming up with your requirements may help to provide the best possible solution.

Regards,
Sam.
Create New Account