温馨提示×

Directory.Exists ()判断指定的文件夹是否存在

小云
178
2023-09-14 03:56:23
栏目: 编程语言

Directory.Exists() 是一个静态方法,用于判断指定的文件夹路径是否存在。

使用方法如下:

string folderPath = "C:\\MyFolder";
if (Directory.Exists(folderPath))
{
// 文件夹存在的逻辑
Console.WriteLine("文件夹存在!");
}
else
{
// 文件夹不存在的逻辑
Console.WriteLine("文件夹不存在!");
}

0