Click here to Skip to main content
15,894,343 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I need source code for windows service, where i can keep track for folders(n_Number)using threading, Now this thread also i can control through Timer.
So pls pls help me.......... I need Thread code which keep track the
Folders and Timer which control thread. Here they dont want to use File
watcher.


Thanks in Adv
Posted
Updated 2-Feb-11 0:03am
v2

Sure. There is an excellent ready-to-use class System.IO.FileSystemWatcher, http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx[^].

—SA
 
Share this answer
 
Comments
Espen Harlinn 2-Feb-11 16:15pm    
Good answer, 5+
Sergey Alexandrovich Kryukov 2-Feb-11 16:35pm    
Thank you a lot. Did you pay attention for John's work? Most interesting. I'll need to dig in later on.
--SA
Espen Harlinn 2-Feb-11 16:46pm    
No, he doesn't seem to appreciate any attention, he may be the fastest reader in the wild west though - often shoots from the hip ;->
Sergey Alexandrovich Kryukov 2-Feb-11 16:54pm    
Sorry, probably I mistyped the above comment as always -- fixed (because I'm becoming a fastest typer in the wild East, often go against a bear with a forked stick).
--SA
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 2-Feb-11 11:44am    
5 of course. Most interesting, especially the conclusion. I just need to try all that.
It looks like you discovered weird things about asynchronous nature of file system, not the class itself. The observed results are surprising. Don't you think it leaves a room for further investigation?

Does it raise concerns about robustness of the file system itself, or this is pure notification stuff?

Practically, some developers complained that if one application creates file for exclusive use, close it and terminates; and then another application opens the same file, they could not deterministically guarantee that the file is really accessible already... From your experience, can it be a concern?

Thank you,
--SA
#realJSOP 3-Feb-11 7:46am    
The file system isn't to blame, it's just reporting what the applications are doing. A file cannot be locked on a per-application basis (I don't think even Unix can do that). Once a file handle is released, that file is available to any other application for whatever manipulation that application has in mind. My sample app in the cited article reflects what various applications do under various circumstances, and given the weirdness, it's important to know the source of the files being watched so you can take appropriate actions.
Sergey Alexandrovich Kryukov 4-Feb-11 2:50am    
Does it mean you deny the concern I explain in my last paragraph above (could not deterministically guarantee)? Personally, I never faced this problem; one my colleague keeps blaming file system, but I can't 100% trust him.

As to notifications of file event, those a very important. If you show any standard file dialog box, you know it processes file list if you add/remove a file in another process. The change in the list is often shown with such a big delay that it's difficult to attribute to the latency of message queues or video. After looking through your article I would think this might be the same thing you've discovered. How do you think?

Thank you.
--SA

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