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