递归
class Program
{
static void Main(string[] args)
{
Director("E:\\aa");
}
static void Director(string dir)
{
DirectoryInfo d = new DirectoryInfo(dir);
FileSystemInfo[] fsinfos = d.GetFileSystemInfos();
foreach (FileSystemInfo fsinfo in fsinfos)
{
if (fsinfo is DirectoryInfo) //判断是否为文件夹
{
Director(fsinfo.FullName);//递归调用
}
else
{
Console.WriteLine(fsinfo.FullName);//输出文件的全部路径
}
}
}