.net 遍歷目錄代碼
public static void readDirectory(string path, int layer)
{
string perStr = "";
for (int i = 0; i < layer; i++)
{
perStr = perStr + "="+" ";
}
DirectoryInfo dirInfo = new DirectoryInfo(path);
FileSystemInfo[] fsis = dirInfo.GetFileSystemInfos();
foreach (FileSystemInfo fsi in fsis)
{
string dirFullName = fsi.FullName;
string dirName = fsi.Name;
print(perStr + dirName);
if (fsi is DirectoryInfo)
{
readDirectory(dirFullName, layer+1);
}
}
}