判断一个路径是否是目录 判断是文件夹还是文件

如题所述

string path = @"D:\aaa";
if (Directory.Exists(path))
{
Console.WriteLine("文件夹");
}
else
{
if (File.Exists(path))
{
Console.WriteLine("文件");
}
else
{
Console.WriteLine("无效路径");
}
}
Console.Read();
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答