
如果您要查找的目录不存在,则会发生DirectoryNotFoundException。
在这里,我们尝试使用GetDirectories()方法查找一个不存在的目录。
示例
using System.IO;
using System;
class Program {
static void Main() {
Directory.GetDirectories("D:\ew\");
}
}由于目录“D:\
ew”不存在,上述代码将产生以下异常。
Unhandled Exception: System.IO.DirectoryNotFoundException: Could not find a part of the path










