我需要复制目录中的文件和目录。假设只有一个级别。给定一个路径,如何确定它是目录还是文件
有一个目录C:\ AAAA,其中包含5个其他目录(没有其他子目录的子目录)和7个文件。
当我打电话:
System.IO.Directory.GetFileSystemEntries("C:\\AAAA");
它返回一个字符串数组。它将包含按照排序顺序排序的条目。所以,当我称之为for-each循环:
foreach(string path in System.IO.Directory.GetFileSystemEntries("C:\\AAAA"))
{
//how to determine path is dictonay or file??
}
从System.IO.Directory.GetFileSystemEntries返回(“C:\ AAAA”)的阵列
那么,如何确定给定的路径是到文件路径或者它是一个目录?
http://stackoverflow.com/questions/1395205/better-way-to-check-if-path-is-a-file-or-a-directory-c-net –