混淆目的是DirectoryInfo.Delete(bool recursive)

Confusion for the purpose of DirectoryInfo.Delete(bool recursive)

方法DirectoryInfo.Delete(bool recursive)接受一个布尔参数,表示删除是否应该递归。

但是这里为什么会有一个选项,不递归怎么删除目录呢?

当递归标志关闭时,您不能删除非空目录。

来自MSDN Documentation

If the DirectoryInfo has no files or subdirectories, this method deletes the DirectoryInfo even if recursive is false. Attempting to delete a DirectoryInfo that is not empty when recursive is false throws an IOException.