C# 中的 DirectoryNotFoundException
如果您尝试查找的目录不存在,则会发生 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
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程语言
C++
C#
MongoDB
MySQL
Javascript
PHP