찾으려는 디렉토리가 존재하지 않으면 DirectoryNotFoundException이 발생합니다.
여기서는 GetDirectories() 메소드를 사용하여 존재하지 않는 디렉토리를 찾으려고 합니다.
예
using System.IO;
using System;
class Program {
static void Main() {
Directory.GetDirectories("D:\\new\\");
}
} 위의 코드는 "D:\\new" 디렉토리가 존재하지 않기 때문에 다음 예외를 생성합니다.
Unhandled Exception: System.IO.DirectoryNotFoundException: Could not find a part of the path