0

我收到了让我(不舒服地)麻木的支持票。WPF 应用程序具有以下代码来删除临时目录:

try
                {
                    Directory.Delete(dir, true);
                }
                catch
                {
                    // ignored
                }

主窗口的调度程序未处理的异常处理程序仅显示带有异常信息的对话框(包括堆栈)。这里是:

System.IO.DirectoryNotFoundException:找不到路径“C:\Users\xxx\AppData\Local\Temp\6\86248143”的一部分。在 System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
在 System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive, Boolean checkHost) 在方法调用 Directory.Delete

谁能指出我为什么在 catch all 块中没有捕获到异常?

4

1 回答 1

0

只需确保选中 CheckBox 即可。它忽略 try catch 块并“在抛出该异常类型时中断”注;我猜是Visual Studio。

于 2017-02-23T07:38:04.117 回答