日期:2014-05-17  浏览次数:21041 次

请问C#怎么判断给出的字符串是文件夹还是文件?
老师让我们完成一个像cmd一样的程序,实现像cmd里的目录、文件的复制移动删除的功能

------解决方案--------------------
这里面有参考代码:http://msdn.microsoft.com/zh-cn/library/system.io.directory.aspx
此外,可以用下面的方法判断文件和目录存在不存在:
File.Exists("xxx");//xxx为你的文件的path
Directory.Exists("xxx");//xxx为你的目录path
------解决方案--------------------
   string path=@"c:\ee\ff\gg\tt.txt";
if(System.IO.Path.HasExtension(path))
{
 //file
}
else
{
//paht
}