c#判断路径是文件还是文件夹

2025-03-12 02:55:09
推荐回答(1个)
回答1:

string str = @"c:\test";
if (System.IO.Directory.Exists(str))
{
//文件夹
}
else if(System.IO.File.Exists(str)) {
//文件
}