using System;
using System.IO;
class Program
{
static void Main()
{
// 定义文件夹路径
string folderPath = @"C:\path\to\your\folder";
// 判断文件夹是否存在
if (Directory.Exists(folderPath))
{
Console.WriteLine("文件夹存在。");
}
else
{
Console.WriteLine("文件夹不存在。");
}
}
}
using System; 和 using System.IO; 是必要的,因为我们需要使用 Console 类来输出信息,以及 Directory 类来检查文件夹是否存在。string folderPath 变量定义要检查的文件夹路径。Directory.Exists(folderPath) 方法来检查指定路径的文件夹是否存在。该方法返回一个布尔值,如果文件夹存在则返回 true,否则返回 false。上一篇:c# zip
下一篇:c#获取时间
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站