Click here to Skip to main content
15,921,793 members
Home / Discussions / C#
   

C#

 
GeneralRe: Windows Service, FileSystemWatcher + Polling [modified] Pin
Paulo Zemek2-Mar-10 9:39
Paulo Zemek2-Mar-10 9:39 
GeneralRe: Windows Service, FileSystemWatcher + Polling Pin
krazykoder3-Mar-10 9:32
krazykoder3-Mar-10 9:32 
GeneralRe: Windows Service, FileSystemWatcher + Polling Pin
Paulo Zemek3-Mar-10 13:33
Paulo Zemek3-Mar-10 13:33 
GeneralRe: Windows Service, FileSystemWatcher + Polling [modified] Pin
krazykoder4-Mar-10 6:26
krazykoder4-Mar-10 6:26 
GeneralRe: Windows Service, FileSystemWatcher + Polling Pin
krazykoder4-Mar-10 8:41
krazykoder4-Mar-10 8:41 
GeneralRe: Windows Service, FileSystemWatcher + Polling Pin
Paulo Zemek4-Mar-10 16:05
Paulo Zemek4-Mar-10 16:05 
GeneralRe: Windows Service, FileSystemWatcher + Polling Pin
krazykoder5-Mar-10 4:36
krazykoder5-Mar-10 4:36 
AnswerRe: Windows Service, FileSystemWatcher + Polling Pin
PIEBALDconsult2-Mar-10 8:44
mvePIEBALDconsult2-Mar-10 8:44 
I have never used FileSystemWatcher (and I know very little about it) -- I always poll; mostly because I have been accessing files on remote systems, running who-knows-what operating system and I've never needed anything like near-real-time processing of new files; polling once an hour has been sufficient.

How I do that depends on the specifics of the situation.

The most general technique I use is to have a database table where I can define what files to seek:

Name           Type1           Type2            Nullable Unique Read only
-------------- --------------- ---------------- -------- ------ ---------
KeyId          System.Guid     uniqueidentifier False    False  False
SearchIn       System.String   varchar(256)     False    False  False
SearchFor      System.String   varchar(256)     False    False  False
DeleteIt       System.Boolean  bit              False    False  False
VersionsToKeep System.Byte     tinyint          False    False  False
LastSearch     System.DateTime datetime         True     False  False


SearchIn contains a directory to search -- e.g. \\someserver\someshare\path...
SearchFor contains a wildcarded filename -- e.g. *.csv
DeleteIt instructs the Service whether or not to delete the file once it has been processed
LastSearch contains the LastWriteTime of the newest file found, it is maintained by the Service


The Service uses a DirectoryInfo's GetFiles method to get a list of files and then checks each file's LastWriteTime to see if it is new and not currently being written to.
Many of you are now freaking out about the performance of this technique as the number of files in the directory grows, and you're correct, but when used in concert with a pro-active archiving and purging regimen this does not become a problem -- the real problem would be in allowing the number of files to grow unfettered in the first place.
AnswerRe: Windows Service, FileSystemWatcher + Polling Pin
Pete O'Hanlon2-Mar-10 10:23
mvePete O'Hanlon2-Mar-10 10:23 
GeneralRe: Windows Service, FileSystemWatcher + Polling Pin
#realJSOP3-Mar-10 3:54
professional#realJSOP3-Mar-10 3:54 
QuestionOUTLFLTR.DLL library - need an answer Pin
chiky_ancutza2-Mar-10 5:20
chiky_ancutza2-Mar-10 5:20 
AnswerRe: OUTLFLTR.DLL library - need an answer Pin
Dan Mos2-Mar-10 5:24
Dan Mos2-Mar-10 5:24 
GeneralRe: OUTLFLTR.DLL library - need an answer Pin
chiky_ancutza2-Mar-10 5:28
chiky_ancutza2-Mar-10 5:28 
GeneralRe: OUTLFLTR.DLL library - need an answer Pin
Dan Mos2-Mar-10 5:38
Dan Mos2-Mar-10 5:38 
AnswerRe: OUTLFLTR.DLL library - need an answer Pin
Luc Pattyn2-Mar-10 5:29
sitebuilderLuc Pattyn2-Mar-10 5:29 
AnswerRe: OUTLFLTR.DLL library - need an answer Pin
Covean2-Mar-10 5:33
Covean2-Mar-10 5:33 
GeneralRe: OUTLFLTR.DLL library - need an answer Pin
chiky_ancutza2-Mar-10 5:45
chiky_ancutza2-Mar-10 5:45 
GeneralRe: OUTLFLTR.DLL library - need an answer Pin
Covean2-Mar-10 5:58
Covean2-Mar-10 5:58 
GeneralRe: OUTLFLTR.DLL library - need an answer Pin
chiky_ancutza2-Mar-10 7:27
chiky_ancutza2-Mar-10 7:27 
GeneralRe: OUTLFLTR.DLL library - need an answer Pin
Covean2-Mar-10 20:33
Covean2-Mar-10 20:33 
GeneralRe: OUTLFLTR.DLL library - need an answer Pin
chiky_ancutza3-Mar-10 2:40
chiky_ancutza3-Mar-10 2:40 
GeneralRe: OUTLFLTR.DLL library - need an answer Pin
Covean3-Mar-10 3:02
Covean3-Mar-10 3:02 
GeneralRe: OUTLFLTR.DLL library - need an answer Pin
chiky_ancutza3-Mar-10 5:35
chiky_ancutza3-Mar-10 5:35 
GeneralRe: OUTLFLTR.DLL library - need an answer Pin
Covean4-Mar-10 0:05
Covean4-Mar-10 0:05 
QuestionQuickTime Audio peak detection Pin
survcopt2-Mar-10 4:57
survcopt2-Mar-10 4:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.