Directory.Exists() 是一个静态方法,用于判断指定的文件夹路径是否存在。
使用方法如下:
string folderPath = "C:\\MyFolder";
if (Directory.Exists(folderPath))
{
// 文件夹存在的逻辑
Console.WriteLine("文件夹存在!");
}
else
{
// 文件夹不存在的逻辑
Console.WriteLine("文件夹不存在!");
}
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>