Reputation: 33
Super odd problem, so I will do my best to explain. Programming C# using FileSystemWatcher and everything works great on USB/hard drives. On a CD/DVD, some files/directories repeatedly crash the program. The unhandledexception states illegal characters in file path; however, it does not appear that there are any. One example that predictably will crash the program is G:\testing\testing\FileCheck\FileCheck\App.config but if I slightly modify to G:\testing\testing\FileCheck2\FileCheck\App.config the program works fine. No illegal characters were removed and the first path ALWAYS fails while the second path ALWAYS works.
Here is the exception args
System.UnhandledExceptionEventArgs G:\testing\testing\FileCheck\FileCheck\App.config
System.ArgumentException: 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._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
If anyone has experience to prevent the error from occurring that would be amazing; otherwise, what is the best way to catch FileSystemWatcher errors so that they do not crash the program.
Upvotes: 0
Views: 120