DirectoryNotFoundException in C#

WBOY
Release: 2023-09-21 16:21:03
forward
1131 people have browsed it

C# 中的 DirectoryNotFoundException

DirectoryNotFoundException occurs if the directory you are looking for does not exist.

Here, we try to use the GetDirectories() method to find a directory that does not exist.

Example

using System.IO;
using System;
class Program {
   static void Main() {
      Directory.GetDirectories("D:\ew\");
   }
}
Copy after login

Since the directory "D:\

ew" does not exist, the above code will generate the following exception.

Unhandled Exception:
System.IO.DirectoryNotFoundException: Could not find a part of the path
Copy after login

The above is the detailed content of DirectoryNotFoundException in C#. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template