c# - Filesystemwatcher causing "Error too many changes at once in directory C:\" -
like few others i'm getting error "error many changes @ once in directory c:\" filesystemwatcher when job. if c:\ clear there many changes. in special case set following parameters:
path = c:\ filter = "test1.txt" notifyfilter = notifyfilters.lastwrite | notifyfilters.filename | notifyfilters.directoryname includesubdirectories = true
i started watcher , let run without problems 4 hours after Í locked pc , came short while later , had error.
now i'm wondering have caused error in case. overlooking important here? or taht includesubdirectories parameter lets check subdirectories of c:\ , ignoring filter of single file exists in c:\ ?
you can increase buffer changes - helped me once.
but every change @ c:\ subdirs can maybe cause lot of workload..
msdn filesystemwatcher.internalbuffersize property
edit:
the filter gets checked @ raising-method - internally every change gets recognized class.
i took framework code can see main raising method .....
private void notifyfilesystemeventargs(int action, string name) { if (this.matchpattern(name)) { switch (action) { case 1: this.oncreated(new filesystemeventargs(watcherchangetypes.created, this.directory, name)); return; case 2: this.ondeleted(new filesystemeventargs(watcherchangetypes.deleted, this.directory, name)); return; case 3: this.onchanged(new filesystemeventargs(watcherchangetypes.changed, this.directory, name)); return; } } }
is using method: "this.matchpattern(name)" - this:
private bool matchpattern(string relativepath) { string filename = system.io.path.getfilename(relativepath); return ((filename != null) && patternmatcher.strictmatchpattern(this.filter.toupper(cultureinfo.invariantculture), filename.toupper(cultureinfo.invariantculture))); }
and can see - filter checked here - far late have suppressed load... ...so way increase buffer size!
Comments
Post a Comment