主要思路:
使用FileInfo遍历主目录下文件,而使用DirectoryInfo通过递归来达到所有的目录。具体编码简化如下:
DirectoryTray(DirectoryInfo folder_DirectoryInfo)
{
FileInfo [] allfile=folder_DirectoryInfo.GetFiles("*.*");
foreach(FileInfo tt in allfile)
{
yourwork(......);
}
DirectoryInfo[] allDirectory=folder_DirectoryInfo.GetDirectories()
foreach(DirectoryInfo dirTmp in allDirectory)
{
DirectoryTray(dirTmp);
}
}
本文出自 “听风看雨” 博客,请务必保留此出处http://6708745.blog.51cto.com/6698745/1150624