public 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);//输出文件的全部路径
textBox2.AppendText("文件名:" + fsinfo.FullName+"\r\n");
textBox2.SelectionStart = this.textBox1.Text.Length;
textBox2.ScrollToCaret();//滚动到最后一行
}
}
}