根据路径删文件或文件夹,怎么判断???
string path = "d:\...\...\... ";
if( ?判断是否是文件类型? )
{
//做文件删除;
}
else
{
//做文件夹的删除;
}
请写判断语句...
谢谢
------解决方案--------------------------------------------------------
/**////如果是文件
if(path is FileInfo)
{}
else
{}
------解决方案--------------------------------------------------------
这样做就行了:
string path = @ "D:\Projects ";
if (System.IO.File.Exists(path))
{
Console.WriteLine( "file ");
}
else if (System.IO.Directory.Exists(path))
{
Console.WriteLine( "directory ");
}