use of filesystemwatcher along with backgroundworker
hi all,
I m creating an application that continuously monitors the file sytem using FileSystemWatcher in the background using the BackGroundWorker class, but i m not getting the event fired when the filename is renamed, plz any1 can help me inthis?
how to implement it......
i dnt knw anything abt using both 2gether. plz help needed.
thanx in advance
thanx for the reply.
Ya i have already did that, but event is not catched only. Can i knw how to implement filesystemwatcher along with the backgroundworker class? so i can knw whether i m on right track or not.
Plz help needed.thanx in advance
Why do you need to do it with Background worker? It doesnot halt your GUI if you use it from the main Thread then why BackgoundWorker is needed?
Try to think and change your logic accrordingly.
;)
might be u r right. Now i changed my logic slightly. I m dng now through console appln and having the filesystemwatcher in that.
ur point is right but i dnt want the gui atall to be included in this process. i want .dll or the exe that run continuously on the device and monitors the renaming of the file system and it any changes then stores it in the database. Console appln would be the soln?
Thanx for the reply
You scenerio tells you better need a piece of application that will run on background without letting user know what's happening in the background.
Then the solution is neither, Console nor Windows Applications, What you do need is a Windows Service that'll automatically be started when the Windows Starts and will Autmatically Close then then Windows Shuts Down doing it database insertion on the background without letting user know what's going on in the background.
Windows Services, dont have a User Interface and Start automatically with Windows Startup, So if you go to Windows or Console Application then you have to do something to put these logics at your own that how to start the Application on Windows Startup and how to hide application Windows.
All these problems are adressed better with Windows Service Solution.
If you need more explaination feel free to write again.
Best Regards and Cheer ;)
thanx alot for ur support. Exactly wht u told is the thing tht i want to implement.
So u want to say that i create the windows service and place it in start up? Will it run continously? I want service that tracks any changes in the filesytem and if any changes occur it stores it in the database. Exactly wht u understood i want to do. plz i dnt knw much abt windows services, plz help me out.
thanx alot in advance
"So u want to say that i create the windows service and place it in start up"
You dont have to do any programing to put Service in startup, It'll automatically be running in the startup. Windows Service has a property I think StartMode that is by default automatic check it. When its start mode is automatic it automacally starts running on Windows Start up.
Windows Service programming is not different from any other .Net application. I'm a bit busy in work at this time cant write more:
There are a lot of articles on the internet and also in MSDN. Try google for "How to Create a Windows Service".
I hope this will work for you. If you have any problem feel free to contact me any time.
Best Regards,
Rizwan Ahmed.