FileSystemWatcher Crash
i using system.io.filesystemwatcher monitor directory on unc path. i have used quite bit in other scripts, , never ran issues. however, past day or so, have been getting random crashes. today running locally, try , identify cause, , able reproduce it, , got following error.
---------------------------system.appdomain
---------------------------
illegal characters in path.
at system.io.path.checkinvalidpathchars(string path, boolean checkadditional)
at system.io.path.getfilename(string path)
at system.io.filesystemwatcher.matchpattern(string relativepath)
at system.io.filesystemwatcher.notifyfilesystemeventargs(int32 action, string name)
at system.io.filesystemwatcher.completionstatuschanged(uint32 errorcode, uint32 numbytes, nativeoverlapped* overlappedpointer)
at system.threading.executioncontext.runinternal(executioncontext executioncontext, contextcallback callback, object state, boolean preservesyncctx)
at system.threading.executioncontext.run(executioncontext executioncontext, contextcallback callback, object state, boolean preservesyncctx)
at system.threading._iocompletioncallback.performiocompletioncallback(uint32 errorcode, uint32 numbytes, nativeoverlapped* poverlap)
however, error appears happening internal notify event, , unable catch error code handle it.
any advice?
justin
justin
the fsw has error event can enabled , call error action block:
https://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.error(v=vs.110).aspx
this allow take action. hardest issue when buffer overflows. action code should short , post job if code complex.
i recommend no more 10 lines of action code in event.
\_(ツ)_/
Windows Server > Windows PowerShell
Comments
Post a Comment