Code:
//Iterates through all directories and subdirectories, printing out each file name it encounters.
public static void printFileNames(DirectoryInfo dir)
{
foreach(FileInfo file in dir.GetFiles())
{
Console.WriteLine(file.Name);
}
foreach(DirectoryInfo subDir in dir.GetDirectories())
{
printFileNames(subDir);
}
}

0 comments:
Post a Comment