仅 CD 上的 FileSystemWatcher 非法字符

问题描述

超级奇怪的问题,所以我会尽力解释。使用 FileSystemWatcher 对 C# 进行编程,一切都在 USB/硬盘驱动器上运行良好。在 CD/DVD 上,某些文件/目录反复使程序崩溃。 unhandledexception 表示文件路径中的非法字符;然而,似乎没有。一个可以预见会导致程序崩溃的例子是 G:\testing\testing\FileCheck\FileCheck\App.config 但如果我稍微修改为 G:\testing\testing\FileCheck2\FileCheck\App.config 该程序运行良好。没有删除非法字符,第一个路径总是失败,而第二个路径总是有效。

这里是异常参数

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,NativeOverlapped* pOVERLAP)

如果有人有防止错误发生的经验,那就太棒了;否则,捕获 FileSystemWatcher 错误以便它们不会使程序崩溃的最佳方法是什么。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...