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