Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I am totally new to C#,,,, I need to start and stop the filesystemwatcher at regular intervals any one please suggest me a way how to stop and start. For example if customer selects 5 min it need's to stop and start every 5min's. As well as it need's to run on a different thread.
Posted
Updated 22-Jun-15 19:12pm
v3
Comments
Sergey Alexandrovich Kryukov 23-Jun-15 2:02am    
Why? It sounds line a possible technology abuse to me. How could it possibly be used?
Also, remember that there is not such thing as 100% guarantee of perfectly regular intervals. It can only be done with some limited accuracy with certain probability. You are not dealing with a real-time system...
—SA
Arkadeep De 23-Jun-15 2:03am    
this may help you.
http://www.codeproject.com/Articles/58740/FileSystemWatcher-Pure-Chaos-Part-of
have a look
Sinisa Hajnal 23-Jun-15 2:36am    
File watcher reacts to file system events such as copying, size change etc...why do you need stopping it? If you have to do it, use timers...but it will of course be dependant on computer restarts, service restarts, etc...you cannot guarantee precision.
ZurdoDev 23-Jun-15 8:37am    
Use a timer.

1 solution

If you are working across a network to a directory with lot's of activity filewatcher can cause heavy network traffic. I've been working on a polled filewatcher that is run from within a timer tick, allowing you to determine the check interval. I maintain a list of files and timestamps in the specified directory. On the next tick I compare the new list to the previous. If a file is missing from the new list it was deleted, if there is a file in the new list that was not in the old list it was added, and if the file timestamp is different the file was changed. For my application I find that a 15 minute interval is sufficient.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900