租用问题

质量为本、客户为根、勇于拼搏、务实创新

< 返回租用问题列表

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

发布时间:2023-09-14 07:55:51

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

Directory.Exists() 是一个静态方法,用于判断指定的文件夹路径是否是存在。
使用方法以下:
```csharp
string folderPath = "C:\MyFolder";
if (Directory.Exists(folderPath))
{
// 文件夹存在的逻辑
Console.WriteLine("文件夹存在!");
}
else
{
// 文件夹不存在的逻辑
Console.WriteLine("文件夹不存在!");
}
```